home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / source / piemnsrc.sit / ParseMenuList.c.bin / ParseMenuList.c
Encoding:
C/C++ Source or Header  |  1989-03-19  |  1.2 KB  |  66 lines  |  [TEXT/KAHL]

  1. /*
  2.  * ParseMenuList.c
  3.  */
  4.  
  5.  
  6. #define    MENU_SEPARATOR        ';'
  7.  
  8.  
  9.  
  10. /*
  11.  * Function:    ParseMenuList
  12.  *
  13.  * Inputs:        char *menuList - string representing the menu to display.
  14.  *
  15.  * Outputs:        menuList will be have all of the mac menu manager specific
  16.  *                strings removed (boldface, circumflex, open paren, dash).
  17.  *
  18.  * Returns:        the number of items in the menu list
  19.  */
  20. int    
  21. ParseMenuList(menuList)
  22.     char *menuList;
  23. {
  24.     char    *cp1;
  25.     char    *cp2;
  26.     int        num_items;
  27.     int        in_item = FALSE;
  28.     
  29.  
  30.     for (cp1 = cp2 = menuList, num_items = 0; *cp2 != '\0'; ++cp2) {
  31.         switch (*cp2) {
  32.             case '^':                /* Item has an icon */
  33.             case '!':                /* Item has a mark */
  34.             case '<':                /* Item has a special style */
  35.             case '/':                /* Item has keyboard equivalent */
  36.                         ++cp2;
  37.                         break;
  38.                         
  39.             case '(':                /* Item is to be dimmed, ignore request */
  40.                         break;
  41.             
  42.             case MENU_SEPARATOR:    /* Menu Separator */
  43.                         ++num_items;
  44.                         *cp1++ = *cp2;
  45.                         in_item = FALSE;
  46.                         break;
  47.                         
  48.             default:
  49.                     *cp1++ = *cp2;
  50.                     in_item = TRUE;
  51.                     break;
  52.         }
  53.     }
  54.     
  55.     /* The last item isn't required to have a separator */
  56.     if (in_item)
  57.         ++num_items;
  58.         
  59.     /* Terminate the string to delete the junk that follows */
  60.     *cp1 = '\0';
  61.     
  62.     return (num_items);
  63. }
  64.  
  65.  
  66.