main(int argc, char **argv) { FILE *fp; int i; progname = argv[0]; for (i = 1; i < argc && argv[i][0] == '-' && argv[i][1] != 0; i++) if (!strcmp(argv[i], "-noquote")) showquotes = 0; else errormsg(Error, "%s: unknown option %s\n", progname, argv[i]); nwindex = new_recognizer(ALPHANUM, SYMBOLS); if (i == argc) { #line 75 "finduses.nw" { FILE *tmp = tmpfile(); char *line; if (tmp == NULL) #line 155 "finduses.nw" errormsg(Fatal, "%s: couldn't open temporary file\n", progname); #line 78 "finduses.nw" while ((line = getline_noweb(stdin)) != NULL) { if (fputs(line, tmp) == EOF) #line 157 "finduses.nw" errormsg(Fatal, "%s: error writing temporary file\n", progname); #line 80 "finduses.nw" if (is_index(line, "defn")) { if (line[strlen(line)-1] == '\n') line[strlen(line)-1] = 0; add_ident(nwindex, line+1+5+1+4+1); } else if (is_index(line, "localdefn")) { if (line[strlen(line)-1] == '\n') line[strlen(line)-1] = 0; add_ident(nwindex, line+1+5+1+9+1); } else if (is_keyword(line, "fatal")) { exit(1); } } rewind(tmp); stop_adding(nwindex); add_use_markers(tmp, stdout); } #line 46 "finduses.nw" } else { #line 56 "finduses.nw" for (; i < argc; i++) if ((fp=fopen(argv[i],"r"))==NULL) errormsg(Error, "%s: couldn't open file %s\n", progname, argv[i]); else { read_ids(fp); fclose(fp); } #line 48 "finduses.nw" stop_adding(nwindex); add_use_markers(stdin, stdout); } nowebexit(NULL); return errorlevel; /* slay warning */ }
static HRESULT WINAPI ScriptDisp_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid) { ScriptDisp *This = ScriptDisp_from_IDispatchEx(iface); dynamic_var_t *var; ident_map_t *ident; function_t *func; TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(bstrName), grfdex, pid); if(!This->ctx) return E_UNEXPECTED; for(ident = This->ident_map; ident < This->ident_map+This->ident_map_cnt; ident++) { if(!strcmpiW(ident->name, bstrName)) { *pid = ident_to_id(This, ident); return S_OK; } } for(var = This->ctx->global_vars; var; var = var->next) { if(!strcmpiW(var->name, bstrName)) { ident = add_ident(This, var->name); if(!ident) return E_OUTOFMEMORY; ident->is_var = TRUE; ident->u.var = var; *pid = ident_to_id(This, ident); return S_OK; } } for(func = This->ctx->global_funcs; func; func = func->next) { if(!strcmpiW(func->name, bstrName)) { ident = add_ident(This, func->name); if(!ident) return E_OUTOFMEMORY; ident->is_var = FALSE; ident->u.func = func; *pid = ident_to_id(This, ident); return S_OK; } } *pid = -1; return DISP_E_UNKNOWNNAME; }
static void read_ids(FILE *in) { char *line; while ((line = getline_noweb(in)) != NULL) { if (line[strlen(line)-1] == '\n') line[strlen(line)-1] = 0; add_ident(nwindex, line); } }