Пример #1
0
int main(int argc, char *argv[])
{
    int len, i;
    char* tagline = NULL;
    File* phile;
    FILE *f;
    char buf[1024];
    int abi = 
#ifndef ARRAYPERSTR
	X_DEFAULT_ABI;
#else
	X_ARRAYPER_ABI;
#endif

    f = stdin;
    if (argc > 1) {
	for (i = 1; i < argc; i++) {
	    if (strcmp (argv[i], "-f") == 0) {
		if (++i < argc)
		    f = fopen (argv[i], "r");
		else
		    return 1;
	    }
	    if (strcmp (argv[i], "-sparcabi") == 0)
		abi = X_SPARC_ABI;
	    if (strcmp (argv[i], "-intelabi") == 0)
		abi = X_INTEL_ABI;
	    if (strcmp (argv[i], "-functionabi") == 0)
		abi = X_FUNCTION_ABI;
	    if (strcmp (argv[i], "-earlyR6bc") == 0 && abi == X_INTEL_ABI)
		abi = X_INTEL_ABI_BC;
	    if (strcmp (argv[i], "-arrayperabi") == 0)
		abi = X_ARRAYPER_ABI;
#ifdef ARRAYPERSTR
	    if (strcmp (argv[i], "-defaultabi") == 0)
		abi = X_DEFAULT_ABI;
#endif
	}
    }

    if (f == NULL) return 1;
    while (fgets(buf, sizeof buf, f)) {
	if (!buf[0] || buf[0] == '\n') 
	    continue;
	if (buf[0] == '!') {
	    if (tagline) continue;
	    tagline = DoComment (buf);
	    continue;
	}
	if (buf[(len = strlen (buf) - 1)] == '\n') buf[len] = '\0';
	DoLine(buf);
    }
    for (phile = file; phile; phile = phile->next) {
	if (abi != X_ARRAYPER_ABI) IndexEntries (phile, abi);
	WriteHeader (tagline, phile, abi);
    }
    WriteSource(tagline, abi);
    return 0;
}
Пример #2
0
int CompleteCommand(
  const char *mstring)
  {
   int i;
   char inchar;
   int depth = 0;
   bool moreThanZero = false;
   bool complete;
   bool error = false;

   if (mstring == NULL) return(0);

   /*===================================================*/
   /* Loop through each character of the command string */
   /* to determine if there is a complete command.      */
   /*===================================================*/

   i = 0;
   while ((inchar = mstring[i++]) != EOS)
     {
      switch(inchar)
        {
         /*======================================================*/
         /* If a carriage return or line feed is found, there is */
         /* at least one completed token in the command buffer,  */
         /* and parentheses are balanced, then a complete        */
         /* command has been found. Otherwise, remove all white  */
         /* space beginning with the current character.          */
         /*======================================================*/

         case '\n' :
         case '\r' :
           if (error) return(-1);
           if (moreThanZero && (depth == 0)) return(1);
           i = DoWhiteSpace(mstring,i);
           break;

         /*=====================*/
         /* Remove white space. */
         /*=====================*/

         case ' ' :
         case '\f' :
         case '\t' :
           i = DoWhiteSpace(mstring,i);
           break;

         /*======================================================*/
         /* If the opening quotation of a string is encountered, */
         /* determine if the closing quotation of the string is  */
         /* in the command buffer. Until the closing quotation   */
         /* is found, a complete command can not be made.        */
         /*======================================================*/

         case '"' :
           i = DoString(mstring,i,&complete);
           if ((depth == 0) && complete) moreThanZero = true;
           break;

         /*====================*/
         /* Process a comment. */
         /*====================*/

         case ';' :
           i = DoComment(mstring,i);
           if (moreThanZero && (depth == 0) && (mstring[i] != EOS))
             {
              if (error) return(-1);
              else return(1);
             }
           else if (mstring[i] != EOS) i++;
           break;

         /*====================================================*/
         /* A left parenthesis increases the nesting depth of  */
         /* the current command by 1. Don't bother to increase */
         /* the depth if the first token encountered was not   */
         /* a parenthesis (e.g. for the command string         */
         /* "red (+ 3 4", the symbol red already forms a       */
         /* complete command, so the next carriage return will */
         /* cause evaluation of red--the closing parenthesis   */
         /* for "(+ 3 4" does not have to be found).           */
         /*====================================================*/

         case '(' :
           if ((depth > 0) || (moreThanZero == false))
             {
              depth++;
              moreThanZero = true;
             }
           break;

         /*====================================================*/
         /* A right parenthesis decreases the nesting depth of */
         /* the current command by 1. If the parenthesis is    */
         /* the first token of the command, then an error is   */
         /* generated.                                         */
         /*====================================================*/

         case ')' :
           if (depth > 0) depth--;
           else if (moreThanZero == false) error = true;
           break;

         /*=====================================================*/
         /* If the command begins with any other character and  */
         /* an opening parenthesis hasn't yet been found, then  */
         /* skip all characters on the same line. If a carriage */
         /* return or line feed is found, then a complete       */
         /* command exists.                                     */
         /*=====================================================*/

         default:
           if (depth == 0)
             {
              if (isprint(inchar) || IsUTF8MultiByteStart(inchar))
                {
                 while ((inchar = mstring[i++]) != EOS)
                   {
                    if ((inchar == '\n') || (inchar == '\r'))
                      {
                       if (error) return(-1);
                       else return(1);
                      }
                   }
                 return(0);
                }
             }
           break;
        }
     }

   /*====================================================*/
   /* Return 0 because a complete command was not found. */
   /*====================================================*/

   return(0);
  }
Пример #3
0
static void text_OnCommand(
  HWND hwnd, 
  int id, 
  HWND hctl, 
  UINT codeNotify)
  {	 
   switch (id) 
	 {
      case ID_EDIT_SET_FONT:
        text_OnFont(hwnd);
        return;

      case ID_EDIT_BALANCE:
        Balance(GetDlgItem(hwnd,ID_EDIT_CONTROL));
        return;

      case ID_EDIT_COMMENT:
        DoComment(GetDlgItem(hwnd,ID_EDIT_CONTROL));
        return;

      case ID_EDIT_UNCOMMENT:
        DoUncomment(GetDlgItem(hwnd,ID_EDIT_CONTROL));
        return;
        
      case ID_HELP_COMPLETE:
        EditComplete(GetDlgItem(hwnd,ID_EDIT_CONTROL));
        return;
       
      case ID_EDIT_UNDO:
        FORWARD_WM_UNDO(GetDlgItem(hwnd, ID_EDIT_CONTROL), 
		 						SendMessage);
        return;
        
      case ID_EDIT_CUT:
        FORWARD_WM_CUT(GetDlgItem(hwnd, ID_EDIT_CONTROL), 
		 						SendMessage);
        return;
         
      case ID_EDIT_COPY:
        FORWARD_WM_COPY(GetDlgItem(hwnd, ID_EDIT_CONTROL), 
		 						SendMessage);
        return;
        
      case ID_EDIT_PASTE:
        FORWARD_WM_PASTE(GetDlgItem(hwnd, ID_EDIT_CONTROL), 
		 						SendMessage);
		FixTextLineEndings(GetDlgItem(hwnd, ID_EDIT_CONTROL));
        return;
         
      case ID_EDIT_CLEAR:
        FORWARD_WM_CLEAR(GetDlgItem(hwnd, ID_EDIT_CONTROL), 
		 						SendMessage);
        return;
         
      case ID_EDIT_SELECT_ALL:
        Edit_SetSel(GetDlgItem(hwnd, ID_EDIT_CONTROL), 0, -1);
        return;
                
      case ID_EDIT_CONTROL:
        text_OnEdit(hwnd,id,hctl,codeNotify);
        return;

      case ID_BUFFER_FIND:
	    SetUpSearch(GetDlgItem(hwnd,ID_EDIT_CONTROL),0);
        return;
        
      case ID_BUFFER_REPLACE:
	    SetUpSearch(GetDlgItem(hwnd,ID_EDIT_CONTROL),1);
        return;
        
      case ID_FILE_PRINT:
	    PrintFile(hwnd);
	    return;
	    
      case ID_FILE_SAVE:
        text_Save(hwnd);
        return;

      case  ID_FILE_SAVE_AS:
        text_SaveAs(hwnd);
        return;
        
      case ID_BUFFER_LOAD:
      case ID_BUFFER_BATCH:
      case ID_BUFFER_LOAD_BUFFER:
        LoadBatchBufferSelection(GetDlgItem(hwnd,ID_EDIT_CONTROL),id);
        return;
	 } 
   
   FORWARD_WM_COMMAND(hwnd, id, hctl, codeNotify, DefMDIChildProc);
  }