Changeset e30ed92 for util.c


Ignore:
Timestamp:
Aug 17, 2009, 10:03:53 PM (15 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
14acbbd
Parents:
8bce750
git-author:
Nelson Elhage <nelhage@mit.edu> (08/17/09 22:03:45)
git-committer:
Nelson Elhage <nelhage@mit.edu> (08/17/09 22:03:53)
Message:
skiptokens: Handle quotes more correctly.

This fixes ctl's bug about not being able to bind the ' key. In
addition, add some tests for skiptokens.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • util.c

    r8bce750 re30ed92  
    158158
    159159const char *skiptokens(const char *buff, int n) {
    160   /* skips n tokens and returns where that would be.
    161    * TODO: handle quotes more sanely. */
    162  
    163   int inquotes=0;
     160  /* skips n tokens and returns where that would be. */
     161  char quote = 0;
    164162  while (*buff && n>0) {
    165163      while (*buff == ' ') buff++;
    166       while (*buff && (inquotes || *buff != ' ')) {
    167         if (*buff == '"' || *buff == '\'') inquotes=!inquotes;
    168         buff++;
     164      while (*buff && (quote || *buff != ' ')) {
     165        if(quote) {
     166          if(*buff == quote) quote = 0;
     167        } else if(*buff == '"' || *buff == '\'') {
     168          quote = *buff;
     169        }
     170        buff++;
    169171      }
    170172      while (*buff == ' ') buff++;
Note: See TracChangeset for help on using the changeset viewer.