Changeset 4b54bd9 in mainline for uspace/lib/pcut/src/preproc.c
- Timestamp:
- 2018-09-12T13:23:03Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3da0ee4
- Parents:
- 275530a4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/pcut/src/preproc.c
r275530a4 r4b54bd9 27 27 */ 28 28 29 # include <stdbool.h>29 #pragma warning(push, 0) 30 30 #include <stdio.h> 31 31 #include <stdlib.h> 32 32 #include <ctype.h> 33 33 #include <string.h> 34 #pragma warning(pop) 35 34 36 35 37 #define MAX_IDENTIFIER_LENGTH 256 … … 37 39 static int counter = 0; 38 40 39 static void print_numbered_identifier(int value, FILE *output) 40 { 41 static void print_numbered_identifier(int value, FILE *output) { 41 42 fprintf(output, "pcut_item_%d", value); 42 43 } 43 44 44 static void print_numbered_identifier2(int value, FILE *output) 45 { 45 static void print_numbered_identifier2(int value, FILE *output) { 46 46 fprintf(output, "pcut_item2_%d", value); 47 47 } 48 48 49 static void print_numbered_identifier3(int value, FILE *output) 50 { 49 static void print_numbered_identifier3(int value, FILE *output) { 51 50 fprintf(output, "pcut_item3_%d", value); 52 51 } … … 57 56 } identifier_t; 58 57 59 static void identifier_init(identifier_t *identifier) 60 { 58 static void identifier_init(identifier_t *identifier) { 61 59 identifier->name[0] = 0; 62 60 identifier->length = 0; 63 61 } 64 62 65 static void identifier_add_char(identifier_t *identifier, char c) 66 { 63 static void identifier_add_char(identifier_t *identifier, char c) { 67 64 if (identifier->length + 1 >= MAX_IDENTIFIER_LENGTH) { 68 65 fprintf(stderr, "Identifier %s is too long, aborting!\n", identifier->name); … … 75 72 } 76 73 77 static void identifier_print_or_expand(identifier_t *identifier, FILE *output) 78 { 74 static void identifier_print_or_expand(identifier_t *identifier, FILE *output) { 79 75 const char *name = identifier->name; 80 76 if (strcmp(name, "PCUT_ITEM_NAME") == 0) { … … 93 89 } 94 90 95 static int is_identifier_char(int c, int inside_identifier) 96 { 97 return isalpha(c) || (c == '_')|| (inside_identifier && isdigit(c));91 static int is_identifier_char(int c, int inside_identifier) { 92 return isalpha(c) || (c == '_') 93 || (inside_identifier && isdigit(c)); 98 94 } 99 95 100 int main(int argc, char *argv[]) 101 { 96 int main(int argc, char *argv[]) { 102 97 FILE *input = stdin; 103 98 FILE *output = stdout; … … 110 105 (void) argv; 111 106 112 while ( true) {107 while (1) { 113 108 int current_char_denotes_identifier; 114 109
Note:
See TracChangeset
for help on using the changeset viewer.