add \ handling withing "" strings with necessary fix to the keybinding menu.

NOTE: this will break ALL current config scripts that have \ in strings.
This commit is contained in:
Bill Currie 2000-03-02 11:38:43 +00:00
parent 1393594ee6
commit 36adeb3bf9
3 changed files with 40 additions and 5 deletions

View File

@ -628,17 +628,43 @@ skipwhite:
if (c == '\"')
{
data++;
while (1)
while (*data && *data!='\"')
{
c = *data++;
if (c=='\"' || !c)
{
com_token[len] = 0;
return data;
if (c=='\\') {
int base=8;
char buf[4];
char *str,*string=buf;
c = *data++;
switch (c) {
case 'a':c='\a';break;
case 'b':c='\b';break;
case 'e':c=27 ;break;
case 'f':c='\f';break;
case 'n':c='\n';break;
case 'r':c='\r';break;
case 'x':
base+=8;
string=data;
goto parse_char_number;
case '0' ... '7':
strncpy(buf,data,3);
parse_char_number:
c=strtol(string,&str,base);
if (str==string)
c='x';
data+=str-string;
break;
}
}
com_token[len] = c;
len++;
}
if (*data)
data++;
com_token[len] = 0;
return data;
}
// parse single characters

View File

@ -787,6 +787,11 @@ void M_Keys_Key (int k)
{
bind_grab = false;
}
else if (k == '\\')
{
snprintf(cmd, sizeof(cmd), "bind \"\\\\\" \"%s\"\n", bindnames[keys_cursor][0]);
Cbuf_InsertText (cmd);
}
else if (k != '`')
{
snprintf(cmd, sizeof(cmd), "bind %s \"%s\"\n", Key_KeynumToString (k), bindnames[keys_cursor][0]);

View File

@ -1486,6 +1486,10 @@ void M_Keys_Key (int k)
{
bind_grab = false;
}
else if (k == '\\')
{
snprintf(cmd, sizeof(cmd), "bind \"\\\\\" \"%s\"\n", bindnames[keys_cursor][0]);
}
else if (k != '`')
{
snprintf(cmd, sizeof(cmd), "bind \"%s\" \"%s\"\n", Key_KeynumToString (k), bindnames[keys_cursor][0]);