コード例 #1
0
ファイル: said.cpp プロジェクト: michailBs/scummvm
static bool parseList(ParseTreeNode* parentNode)
{
	// Store current state for rolling back if we fail
	int curToken = said_token;
	int curTreePos = said_tree_pos;
	ParseTreeNode* curRightChild = parentNode->right;

	bool found;

	ParseTreeNode* newParent = parentNode;

	found = parseListEntry(newParent);

	if (found) {

		newParent = newParent->right;

		found = parseComma(newParent);

		return true;

	}

	// Rollback
	said_token = curToken;
	said_tree_pos = curTreePos;
	parentNode->right = curRightChild;
	return false;
}
コード例 #2
0
ファイル: io.c プロジェクト: cbeust/banker-amiga
void
readOptionsFile()
{
   FILE *f;
   int isOpen;
   char *p, keyword[80], *pk, buffer[256];
   char *name = (CL_Struct.optionsFile ? CL_Struct.optionsFile : OPTIONSFILENAME);

   f = fopen(name, "r");
   if (! f) {
      myMsg2("couldn't open the configuration file", name);
      goto close;
   }

   while (1) {
      p = fgets(buffer, 256, f);
      if (p == NULL) goto close;
      if (*p == '#' || *p == '\n') continue;      /* skip comments */
      if (feof(f)) goto close;
      pk = keyword;
      while (! isblank(*p)) *pk++ = *p++;
      *pk++ = '\0';               /* now the keyword is recorded */
      while (isblank (*p)) p++;  /* and p is on the first data field */

      if (stricmp(keyword, "mainwindow") == 0 ||
          stricmp(keyword, "list") == 0 ||
          stricmp(keyword, "getentry") == 0 ||
          stricmp(keyword, "automatic") == 0) {

         sscanf(p, " %d\n", & isOpen);
         if (keyword[0] == 'm' || keyword[0] == 'M') {
            OF_Struct.mainWindow.isOpen = isOpen;
         }
         else if (keyword[0] == 'l' || keyword[0] == 'L') {
            OF_Struct.list.isOpen = isOpen;
         }
         else if (keyword[0] == 'g' || keyword[0] == 'G') {
            OF_Struct.getEntry.isOpen = isOpen;
         }
         else if (keyword[0] == 'a' || keyword[0] == 'A') {
            OF_Struct.automatic.isOpen = isOpen;
         }
      }

      else if (stricmp(keyword, "autosave") == 0) {
         OF_Struct.autoSave = atoi(p);
      }

      else if (stricmp(keyword, "defaultdate") == 0) {
         char *df;
         OF_Struct.defaultDate = df = (char *) malloc(strlen(p));
         while (*p && *p != '\n') *df++ = *p++; /* to prevent an '\n' in the date */
         *df = '\0';
      }

      else if (stricmp(keyword, "dateformat") == 0) {
         char *df;
         OF_Struct.dateFormat = df = (char *) malloc(strlen(p));
         while (*p && *p != '\n') *df++ = *p++; /* to prevent an '\n' in the date */
         *df = '\0';
      }

      else if (stricmp(keyword, "printformat") == 0 ||
               stricmp(keyword, "displayformat") == 0 ||
               stricmp(keyword, "exportformat") == 0) {
         if (keyword[0] == 'p')  PrintFormatStructure = *parseFormatString(p);
         else if (keyword[0] == 'e') ExportFormatStructure = *parseFormatString(p);
         else {
            parseListEntry(p, DisplayEntryFormat);
            DisplayFormatStructure = *parseFormatString(p);
         }
      }


      else myMsg2("unknown keyword '%s'", keyword);
      while (*p && *p != '\n') p++;
   }
close:
   fclose(f);
}