示例#1
0
static int findWord(const char *zText,
                    const char **pzWordStart, const char **pzWordEnd){
  int r;
  while( ascii_isspace(*zText) ){
    zText++;
  }
  *pzWordStart = zText;
  while( ascii_isalnum(*zText) || *zText=='_' ){
    zText++;
  }
  r = zText>*pzWordStart;  
  *pzWordEnd = zText;
  return r;
}
// Convert a file name into a valid identifier.
string FilenameIdentifier(const string& filename) {
  string result;
  for (unsigned int i = 0; i < filename.size(); i++) {
    if (ascii_isalnum(filename[i])) {
      result.push_back(filename[i]);
    } else {
      // Not alphanumeric.  To avoid any possibility of name conflicts we
      // use the hex code for the character.
      result.push_back('_');
      char buffer[kFastToBufferSize];
      result.append(FastHexToBuffer(static_cast<uint8_t>(filename[i]), buffer));
    }
  }
  return result;
}