Bool HandleVModDef(VModDef *stmt,unsigned mergeMode,VModInfo *info) { register int i,bit,nextFree; ExprResult mod; XkbServerMapPtr srv; XkbNamesPtr names; Atom stmtName; srv= info->xkb->server; names= info->xkb->names; stmtName= XkbInternAtom(info->xkb->dpy,XkbAtomGetString(NULL,stmt->name), False); for (i=0,bit=1,nextFree= -1;i<XkbNumVirtualMods;i++,bit<<=1) { if (info->defined&bit) { if (names->vmods[i]==stmtName) { /* already defined */ info->available|= bit; if (stmt->value==NULL) return True; else { char *str1,*str2 = ""; if (!ExprResolveModMask(stmt->value,&mod,NULL,NULL)) { str1= XkbAtomText(NULL,stmt->name,XkbMessage); ACTION1("Declaration of %s ignored\n",str1); return False; } if (mod.uval==srv->vmods[i]) return True; str1= XkbAtomText(NULL,stmt->name,XkbMessage); WARN1("Virtual modifier %s multiply defined\n",str1); str1= XkbModMaskText(srv->vmods[i],XkbCFile); if (mergeMode==MergeOverride) { str2= str1; str1= XkbModMaskText(mod.uval,XkbCFile); } ACTION2("Using %s, ignoring %s\n",str1,str2); if (mergeMode==MergeOverride) srv->vmods[i]= mod.uval; return True; } } } else if (nextFree<0) nextFree= i; } if (nextFree<0) { ERROR1("Too many virtual modifiers defined (maximum %d)\n", XkbNumVirtualMods); ACTION("Exiting\n"); return False; } info->defined|= (1<<nextFree); info->newlyDefined|= (1<<nextFree); info->available|= (1<<nextFree); names->vmods[nextFree]= stmtName; if (stmt->value==NULL) return True; if (ExprResolveModMask(stmt->value,&mod,NULL,NULL)) { srv->vmods[nextFree]= mod.uval; return True; } ACTION1("Declaration of %s ignored\n", XkbAtomText(NULL,stmt->name,XkbMessage)); return False; }
static Bool parseArgs(int argc, char *argv[]) { register int i, tmp; i = strlen(argv[0]); tmp = strlen("xkblist"); if ((i >= tmp) && (strcmp(&argv[0][i - tmp], "xkblist") == 0)) { xkblist = True; } for (i = 1; i < argc; i++) { int itmp; if ((argv[i][0] != '-') || (uStringEqual(argv[i], "-"))) { if (!xkblist) { if (inputFile == NULL) inputFile = argv[i]; else if (outputFile == NULL) outputFile = argv[i]; else if (warningLevel > 0) { WARN("Too many file names on command line\n"); ACTION3 ("Compiling %s, writing to %s, ignoring %s\n", inputFile, outputFile, argv[i]); } } else if (!AddMatchingFiles(argv[i])) return False; } else if ((strcmp(argv[i], "-?") == 0) || (strcmp(argv[i], "-help") == 0)) { Usage(argc, argv); exit(0); } else if ((strcmp(argv[i], "-a") == 0) && (!xkblist)) { showImplicit = True; } else if ((strcmp(argv[i], "-C") == 0) && (!xkblist)) { if ((outputFormat != WANT_DEFAULT) && (outputFormat != WANT_C_HDR)) { if (warningLevel > 0) { WARN("Multiple output file formats specified\n"); ACTION1("\"%s\" flag ignored\n", argv[i]); } } else outputFormat = WANT_C_HDR; } #ifdef DEBUG else if (strcmp(argv[i], "-d") == 0) { if ((i >= (argc - 1)) || (!isdigit(argv[i + 1][0]))) { debugFlags = 1; } else { if (sscanf(argv[++i], "%i", &itmp) == 1) debugFlags = itmp; } INFO1("Setting debug flags to %d\n", debugFlags); } #endif else if ((strcmp(argv[i], "-dflts") == 0) && (!xkblist)) { computeDflts = True; } else if (strcmp(argv[i], "-em1") == 0) { if (++i >= argc) { if (warningLevel > 0) { WARN("No pre-error message specified\n"); ACTION("Trailing \"-em1\" option ignored\n"); } } else if (preErrorMsg != NULL) { if (warningLevel > 0) { WARN("Multiple pre-error messsages specified\n"); ACTION2("Compiling %s, ignoring %s\n", preErrorMsg, argv[i]); } } else preErrorMsg = argv[i]; } else if (strcmp(argv[i], "-emp") == 0) { if (++i >= argc) { if (warningLevel > 0) { WARN("No error prefix specified\n"); ACTION("Trailing \"-emp\" option ignored\n"); } } else if (errorPrefix != NULL) { if (warningLevel > 0) { WARN("Multiple error prefixes specified\n"); ACTION2("Compiling %s, ignoring %s\n", errorPrefix, argv[i]); } } else errorPrefix = argv[i]; } else if (strcmp(argv[i], "-eml") == 0) { if (++i >= argc) { if (warningLevel > 0) { WARN("No post-error message specified\n"); ACTION("Trailing \"-eml\" option ignored\n"); } } else if (postErrorMsg != NULL) { if (warningLevel > 0) { WARN("Multiple post-error messages specified\n"); ACTION2("Compiling %s, ignoring %s\n", postErrorMsg, argv[i]); } } else postErrorMsg = argv[i]; } else if ((strncmp(argv[i], "-I", 2) == 0) && (!xkblist)) { if (!XkbAddDirectoryToPath(&argv[i][2])) { ACTION("Exiting\n"); exit(1); } } else if ((strncmp(argv[i], "-i", 2) == 0) && (!xkblist)) { if (++i >= argc) { if (warningLevel > 0) WARN("No device ID specified\n"); } device_id = atoi(argv[i]); } else if ((strncmp(argv[i], "-l", 2) == 0) && (!xkblist)) { if (outputFormat != WANT_DEFAULT) { if (warningLevel > 0) { WARN("Multiple output file formats specified\n"); ACTION1("\"%s\" flag ignored\n", argv[i]); } } else { if (argv[i][2] != '\0') setVerboseFlags(&argv[i][2]); xkblist = True; if ((inputFile) && (!AddMatchingFiles(inputFile))) return False; else inputFile = NULL; if ((outputFile) && (!AddMatchingFiles(outputFile))) return False; else outputFile = NULL; } } else if ((strcmp(argv[i], "-m") == 0) || (strcmp(argv[i], "-map") == 0)) { if (++i >= argc) { if (warningLevel > 0) { WARN("No map name specified\n"); ACTION1("Trailing \"%s\" option ignored\n", argv[i - 1]); } } else if (xkblist) { if (!AddMapOnly(argv[i])) return False; } else if (inputMap != NULL) { if (warningLevel > 0) { WARN("Multiple map names specified\n"); ACTION2("Compiling %s, ignoring %s\n", inputMap, argv[i]); } } else inputMap = argv[i]; } else if ((strcmp(argv[i], "-merge") == 0) && (!xkblist)) { /* Ignored */ } else if (strcmp(argv[i], "-o") == 0) { if (++i >= argc) { if (warningLevel > 0) { WARN("No output file specified\n"); ACTION("Trailing \"-o\" option ignored\n"); } } else if (outputFile != NULL) { if (warningLevel > 0) { WARN("Multiple output files specified\n"); ACTION2("Compiling %s, ignoring %s\n", outputFile, argv[i]); } } else outputFile = argv[i]; } else if (((strcmp(argv[i], "-opt") == 0) || (strcmp(argv[i], "optional") == 0)) && (!xkblist)) { if (++i >= argc) { if (warningLevel > 0) { WARN("No optional components specified\n"); ACTION1("Trailing \"%s\" option ignored\n", argv[i - 1]); } } else { char *tmp2; for (tmp2 = argv[i]; (*tmp2 != '\0'); tmp2++) { switch (*tmp2) { case 'c': case 'C': optionalParts |= XkmCompatMapMask; break; case 'g': case 'G': optionalParts |= XkmGeometryMask; break; case 'k': case 'K': optionalParts |= XkmKeyNamesMask; break; case 's': case 'S': optionalParts |= XkmSymbolsMask; break; case 't': case 'T': optionalParts |= XkmTypesMask; break; default: if (warningLevel > 0) { WARN1 ("Illegal component for %s option\n", argv[i - 1]); ACTION1 ("Ignoring unknown specifier \"%c\"\n", (unsigned int) *tmp2); } break; } } } } else if (strncmp(argv[i], "-p", 2) == 0) { if (isdigit(argv[i][2])) { if (sscanf(&argv[i][2], "%i", &itmp) == 1) dirsToStrip = itmp; } else if ((i < (argc - 1)) && (isdigit(argv[i + 1][0]))) { if (sscanf(argv[++i], "%i", &itmp) == 1) dirsToStrip = itmp; } else { dirsToStrip = 0; } if (warningLevel > 5) INFO1("Setting path count to %d\n", dirsToStrip); } else if (strncmp(argv[i], "-R", 2) == 0) { if (argv[i][2] == '\0') { if (warningLevel > 0) { WARN("No root directory specified\n"); ACTION("Ignoring -R option\n"); } } else if (rootDir != NULL) { if (warningLevel > 0) { WARN("Multiple root directories specified\n"); ACTION2("Using %s, ignoring %s\n", rootDir, argv[i]); } } else { rootDir = &argv[i][2]; if (warningLevel > 8) { WARN1("Changing root directory to \"%s\"\n", rootDir); } if ((chdir(rootDir) < 0) && (warningLevel > 0)) { WARN1("Couldn't change directory to \"%s\"\n", rootDir); ACTION("Root directory (-R) option ignored\n"); rootDir = NULL; } } } else if ((strcmp(argv[i], "-synch") == 0) || (strcmp(argv[i], "-s") == 0)) { synch = True; } else if (strncmp(argv[i], "-v", 2) == 0) { char *str; if (argv[i][2] != '\0') str = &argv[i][2]; else if ((i < (argc - 1)) && (argv[i + 1][0] != '-')) str = argv[++i]; else str = NULL; if (str) setVerboseFlags(str); } else if (strncmp(argv[i], "-w", 2) == 0) { if ((i >= (argc - 1)) || (!isdigit(argv[i + 1][0]))) { warningLevel = 0; if (isdigit(argv[i][1])) if (sscanf(&argv[i][1], "%i", &itmp) == 1) warningLevel = itmp; } else { if (sscanf(argv[++i], "%i", &itmp) == 1) warningLevel = itmp; } } else if ((strcmp(argv[i], "-xkb") == 0) && (!xkblist)) { if ((outputFormat != WANT_DEFAULT) && (outputFormat != WANT_XKB_FILE)) { if (warningLevel > 0) { WARN("Multiple output file formats specified\n"); ACTION1("\"%s\" flag ignored\n", argv[i]); } } else outputFormat = WANT_XKB_FILE; } else if ((strcmp(argv[i], "-xkm") == 0) && (!xkblist)) { if ((outputFormat != WANT_DEFAULT) && (outputFormat != WANT_XKM_FILE)) { if (warningLevel > 0) { WARN("Multiple output file formats specified\n"); ACTION1("\"%s\" flag ignored\n", argv[i]); } } else outputFormat = WANT_XKM_FILE; } else { ERROR1("Unknown flag \"%s\" on command line\n", argv[i]); Usage(argc, argv); return False; } } if (xkblist) inputFormat = INPUT_XKB; else if (inputFile == NULL) { ERROR("No input file specified\n"); return False; } else if (uStringEqual(inputFile, "-")) { inputFormat = INPUT_XKB; } #ifndef WIN32 else if (strchr(inputFile, ':') == NULL) { #else else if ((strchr(inputFile, ':') == NULL) || (strlen(inputFile) > 2 && isalpha(inputFile[0]) && inputFile[1] == ':' && strchr(inputFile + 2, ':') == NULL)) { #endif int len; len = strlen(inputFile); if (inputFile[len - 1] == ')') { char *tmp; if ((tmp = strchr(inputFile, '(')) != NULL) { *tmp = '\0'; inputFile[len - 1] = '\0'; tmp++; if (*tmp == '\0') { WARN("Empty map in filename\n"); ACTION("Ignored\n"); } else if (inputMap == NULL) { inputMap = uStringDup(tmp); } else { WARN("Map specified in filename and with -m flag\n"); ACTION1("map from name (\"%s\") ignored\n", tmp); } } else { ERROR1("Illegal name \"%s\" for input file\n", inputFile); return False; } } if ((len > 4) && (strcmp(&inputFile[len - 4], ".xkm") == 0)) { inputFormat = INPUT_XKM; } else { FILE *file; file = fopen(inputFile, "r"); if (file) { if (XkmProbe(file)) inputFormat = INPUT_XKM; else inputFormat = INPUT_XKB; fclose(file); } else { fprintf(stderr, "Cannot open \"%s\" for reading\n", inputFile); return False; } } } else { inDpyName = inputFile; inputFile = NULL; inputFormat = INPUT_XKM; } if (outputFormat == WANT_DEFAULT) { if (xkblist) outputFormat = WANT_LISTING; else if (inputFormat == INPUT_XKB) outputFormat = WANT_XKM_FILE; else outputFormat = WANT_XKB_FILE; } if ((outputFormat == WANT_LISTING) && (inputFormat != INPUT_XKB)) { if (inputFile) ERROR("Cannot generate a listing from a .xkm file (yet)\n"); else ERROR("Cannot generate a listing from an X connection (yet)\n"); return False; } if (xkblist) { if (outputFile == NULL) outputFile = uStringDup("-"); else if (strchr(outputFile, ':') != NULL) { ERROR("Cannot write a listing to an X connection\n"); return False; } } else if ((!outputFile) && (inputFile) && uStringEqual(inputFile, "-")) { int len = strlen("stdin") + strlen(fileTypeExt[outputFormat]) + 2; outputFile = uTypedCalloc(len, char); if (outputFile == NULL) { WSGO("Cannot allocate space for output file name\n"); ACTION("Exiting\n"); exit(1); } sprintf(outputFile, "stdin.%s", fileTypeExt[outputFormat]); } else if ((outputFile == NULL) && (inputFile != NULL))