-
- name_=fname;
-
- // now read the file
- LyXLex lex(0,0);
- lex.setFile(f());
-
- bool error=false;
- string str;
- int n;
-
- while(lex.IsOK() && !error) {
-
- switch(lex.lex()){
- case LyXLex::LEX_FEOF :
- lyxerr[Debug::KBMAP] << "End of parsing of .cdef file"
- << endl;
- break;
- default:
- // Get Integer
- n=lex.GetInteger();
- if (n<0) {
- error=true;
- continue;
- }
-
- // Get String
- lex.next(true);
- str=lex.GetString();
-
- Cdef* tempc=new Cdef;
- tempc->str=str;
- tempc->ic=n;
- tempc->next=map_;
- map_=tempc;
-
+ name_ = fname;
+
+ string line;
+ // Ok, I'll be the first to admit that this is probably not
+ // the fastest way to parse the cdef files, but I though it
+ // was a bit neat. Anyway it is wrong to use the lyxlex parse
+ // without the use of a keyword table.
+ regex reg("^([12][0-9][0-9])[ \t]+\"([^ ]+)\".*");
+ while (getline(ifs, line)) {
+ smatch sub;
+ if (regex_match(line, sub, reg)) {
+ int const n = convert<int>(sub.str(1));
+ string const str = sub.str(2);