comparison src/misc2.c @ 440:eb531146be0e v7.0114

updated for version 7.0114
author vimboss
date Sat, 23 Jul 2005 22:25:46 +0000
parents 84825cc6f049
children dd9db57ee7ce
comparison
equal deleted inserted replaced
439:8d2b705a5a51 440:eb531146be0e
5555 return -1; /* no match */ 5555 return -1; /* no match */
5556 return 1; 5556 return 1;
5557 } 5557 }
5558 #endif 5558 #endif
5559 5559
5560 #if defined(FEAT_PRINTER) || defined(PROTO)
5561 /*
5562 * Parse a list of options in the form
5563 * option:value,option:value,option:value
5564 *
5565 * "value" can start with a number which is parsed out, e.g.
5566 * margin:12mm
5567 *
5568 * Returns error message for an illegal option, NULL otherwise.
5569 * Only used for the printer at the moment...
5570 */
5571 char_u *
5572 parse_list_options(option_str, table, table_size)
5573 char_u *option_str;
5574 option_table_T *table;
5575 int table_size;
5576 {
5577 char_u *stringp;
5578 char_u *colonp;
5579 char_u *commap;
5580 char_u *p;
5581 int idx = 0; /* init for GCC */
5582 int len;
5583
5584 for (idx = 0; idx < table_size; ++idx)
5585 table[idx].present = FALSE;
5586
5587 /*
5588 * Repeat for all comma separated parts.
5589 */
5590 stringp = option_str;
5591 while (*stringp)
5592 {
5593 colonp = vim_strchr(stringp, ':');
5594 if (colonp == NULL)
5595 return (char_u *)N_("E550: Missing colon");
5596 commap = vim_strchr(stringp, ',');
5597 if (commap == NULL)
5598 commap = option_str + STRLEN(option_str);
5599
5600 len = (int)(colonp - stringp);
5601
5602 for (idx = 0; idx < table_size; ++idx)
5603 if (STRNICMP(stringp, table[idx].name, len) == 0)
5604 break;
5605
5606 if (idx == table_size)
5607 return (char_u *)N_("E551: Illegal component");
5608
5609 p = colonp + 1;
5610 table[idx].present = TRUE;
5611
5612 if (table[idx].hasnum)
5613 {
5614 if (!VIM_ISDIGIT(*p))
5615 return (char_u *)N_("E552: digit expected");
5616
5617 table[idx].number = getdigits(&p); /*advances p*/
5618 }
5619
5620 table[idx].string = p;
5621 table[idx].strlen = (int)(commap - p);
5622
5623 stringp = commap;
5624 if (*stringp == ',')
5625 ++stringp;
5626 }
5627
5628 return NULL;
5629 }
5630
5631
5632 #endif /*FEAT_PRINTER*/
5633
5634 /* 5560 /*
5635 * The putenv() implementation below comes from the "screen" program. 5561 * The putenv() implementation below comes from the "screen" program.
5636 * Included with permission from Juergen Weigert. 5562 * Included with permission from Juergen Weigert.
5637 * See pty.c for the copyright notice. 5563 * See pty.c for the copyright notice.
5638 */ 5564 */