int main( int argc, char **argv ) { if ( remove_comment( stdin, stdout ) != 0 ) { printf( "error: error when removing comments\n" ); return 0; } return 0; }
void zip_file::load(const std::vector<unsigned char> &bytes) { reset(); buffer_.assign(bytes.begin(), bytes.end()); remove_comment(); start_read(); }
int main(int ac, char **av) { int i; char **tab; int fd; if (ac != 2) return (0); i = 1; while (av[i]) { if ((file_type(av[i])) == -1) my_putstr("Your file must be .s\n"); else { if ((tab = pars_file(av[i])) != NULL) if ((fd = create_file_cor(av[i])) != -1) { tab = remove_comment(tab); parser_zjmp(tab); check_twice(tab); fill_file_cor(fd, tab); } } i++; } return (0); }
int GetOption (char *str, char *option, int option_len, char *value, int val_len) { char *argv[2]; char key [MENU_TITLE_BUF_LEN +1] = {0}; char val [VALUE_LEN +1] = {0}; char *p; int argc; argv[0] = key; argv[1] = val; //split string to two part,key and value ,splited by SPACE or TAB argc = split_str (str, argv); //if split to two part, return 2. if( argc < 2 ) return -1; //remove SPACE and TAB from key and val header and tail. p = trim (key); //copy to buffer. strncpy (option, p, option_len - 1); p = trim (val); //remove comment data from string. remove_comment(p); strncpy (value, p, val_len -1); return 0; }
void zip_file::load(std::istream &stream) { reset(); buffer_.assign(std::istreambuf_iterator<char>(stream), std::istreambuf_iterator<char>()); remove_comment(); start_read(); }
int main() { char input[10000], output[10000]; int n = 0; while(scanf("%c", &input[n]) != EOF) n++; printf("%d\n", remove_comment(input,output)); printf("%s\n", output); return 0; }
static char *get_string(const char *name, const char *arg) { char *s = xstrdup(arg); remove_comment(s); if (DEBUG_CONFIG(2)) fprintf(dbgout, "%s -> '%s'\n", name, s); return s; }
int oly_parse_cmd(struct command *c, char *s) { c->cmd = 0; c->fuzzy = FALSE; c->use_skill = 0; while (iswhite(*s)) s++; remove_comment(s); remove_ctrl_chars(s); if (c->line) my_free(c->line); c->line = str_save(s); if (*s == '&') { c->conditional = 1; s++; } else if (*s == '?') { c->conditional = 2; s++; } else c->conditional = 0; if (c->parsed_line) my_free(c->parsed_line); c->parsed_line = str_save(s); c->parse = parse_line(c->parse, c->parsed_line); if (ilist_len(c->parse) > 0) { int i; i = find_command(c->parse[0]); if (i > 0) { c->cmd = i; if (fuzzy_find) c->fuzzy = TRUE; } else return FALSE; } return TRUE; }
int GetTitle(const char *str,char * title, int title_buf_len) { char *argv[2]; char key [MENU_TITLE_BUF_LEN +1] = {0}; char value [VALUE_LEN +1] = {0}; char *p; int argc, len; argv[0] = key; argv[1] = value; //Parse string. argc = split_str (str, argv); if( argc < 1 ) return -1; if( argc == 1 ) { //Support for OLD style lable len = strlen (argv[0]); if( argv[0][len -1] == ':') { argv[0][len -1] = '\0'; p=trim(argv[0]); //remove SPACE and TAB from begin and end of string. strncpy(title,p,title_buf_len); return 0; } } else { //remove SPACE and TAB from begin and end of string. p = trim (key); //check key. if( strcasecmp (p, "title") == 0 ) { //remove SPACE and TAB from begin and end of string. p = trim (value); //remove comment data from string. remove_comment(p); strncpy (title, p, title_buf_len); return 0; } } return -1; }
int main(int argc, char **argv) { if ( argc < 2 ) { err( "usage: gimp_palette_convert <*.map> <output>" ); } unsigned int data_sz = 0; char * data = NULL; if ( !(data=get_gimp_palette( argv[1], &data_sz)) ) { char buf[100]; sprintf( buf, "couldn't get palette: \"%s\"\n", argv[1] ); err( buf ); } // what to call output char outfile[256]; if ( argc > 2 ) { strcpy( outfile, argv[2] ); } else { sprintf( outfile, "%s.map", argv[1] ); } FILE *fp = fopen( outfile, "wb" ); header( fp ); printf( "data size of input file: %u\n", data_sz ); char * p = data; unsigned int i = 0; while ( i < data_sz ) { // trim any white space i += trim_whitespace( &p, i, data_sz ); if ( i >= data_sz ) break; // get length of line to newline int len = linelen( p, i, data_sz ); // check if line is a comment, if so remove it remove_comment( &p, &i, &len, data_sz ); if ( i >= data_sz ) break; // get a line char line[256]; strncpy( line, p, len ); line[len] = '\0'; // translate line values into 1 MapTile definition and print it printTile( line, len, fp ); // advance past end of line, to first character past the '\n' //i += eatline( &data ); p += len; i += len; } fclose( fp ); free( data ); printf( "creating: %s\n", outfile ); return 0; }
static bool process_config_parameter(const parm_desc *arg, char *val, priority_t precedence) /* returns true if ok, false if error */ { bool ok = true; if (arg->addr.v == NULL) return ok; switch (arg->type) { case CP_BOOLEAN: { *arg->addr.b = str_to_bool(val); if (DEBUG_CONFIG(2)) fprintf(dbgout, "%s -> %s\n", arg->name, *arg->addr.b ? "Yes" : "No"); break; } case CP_INTEGER: { remove_comment(val); if (!xatoi(arg->addr.i, val)) return false; if (DEBUG_CONFIG(2)) fprintf(dbgout, "%s -> %d\n", arg->name, *arg->addr.i); break; } case CP_DOUBLE: { remove_comment(val); if (!xatof(arg->addr.d, val)) return false; if (DEBUG_CONFIG(2)) fprintf(dbgout, "%s -> %f\n", arg->name, *arg->addr.d); break; } case CP_CHAR: { *arg->addr.c = *val; if (DEBUG_CONFIG(2)) fprintf(dbgout, "%s -> '%c'\n", arg->name, *arg->addr.c); break; } case CP_STRING: { *arg->addr.s = xstrdup(val); if (DEBUG_CONFIG(2)) fprintf(dbgout, "%s -> '%s'\n", arg->name, *arg->addr.s); break; } case CP_DIRECTORY: { char *dir = tildeexpand(val, true); if (DEBUG_CONFIG(2)) fprintf(dbgout, "%s -> '%s'\n", arg->name, dir); if (setup_wordlists(dir, precedence) != 0) exit(EX_ERROR); xfree(dir); break; } case CP_FUNCTION: { ok = (*arg->addr.f)((unsigned char *)val); if (DEBUG_CONFIG(2)) fprintf(dbgout, "%s -> '%s'\n", arg->name, val); break; } case CP_WORDLIST: { char c = *val; switch (c) { case 'c': wl_mode = WL_M_COMBINED; break; case 's': wl_mode = WL_M_SEPARATE; break; default: fprintf(stderr, "Unknown wordlist type - '%s'.\n", val); exit(EX_ERROR); } if (DEBUG_CONFIG(2)) fprintf(dbgout, "%s -> '%s'\n", arg->name, val); break; } default: { ok = false; break; } } return ok; }
int AssembleString(char* str, const char* initialFilename) { curFile = initialFilename; curLine = 1; ClearStatus(); int nextLineIncr = 0; char* nextStr = NULL; for (; str; str = nextStr, curLine += nextLineIncr) { size_t len = strcspn(str, "\n"); int linedelim = str[len]; str[len] = 0; nextStr = linedelim ? (str + len + 1) : NULL; nextLineIncr = linedelim == '\n' ? 1 : 0; char* line = trim_whitespace(remove_comment(str)); char* colonPos = NULL; for (;;) { colonPos = strchr(line, ':'); if (!colonPos) break; *colonPos = 0; char* labelName = line; line = trim_whitespace(colonPos + 1); if (!validateIdentifier(labelName)) return throwError("invalid label name: %s\n", labelName); std::pair<labelTableIter,bool> ret = g_labels.insert( std::pair<std::string,size_t>(labelName, BUF.size()) ); if (!ret.second) return throwError("duplicate label: %s\n", labelName); //printf("Label: %s\n", labelName); }; if (!*line) continue; if (*line == '#') { line = trim_whitespace(line + 1); nextLineIncr = 0; size_t pos = strcspn(line, " \t"); line[pos] = 0; curLine = atoi(line); line = trim_whitespace(line + pos + 1); if (*line == '"') { line ++; line[strlen(line)-1] = 0; } curFile = line; continue; } char* tok = mystrtok_spc(line); safe_call(ProcessCommand(tok)); } if (g_stackPos) return throwError("unclosed block(s)\n"); safe_call(FixupLabelRelocations()); return 0; }