MCPcopy Create free account
hub / github.com/assaultcube/AC / format

Function format

source/src/command.cpp:1087–1110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1085COMMANDF(concatword, "w", (const char *s) { result(s); });
1086
1087void format(char **args, int numargs)
1088{
1089 vector<char> s;
1090 const char *f = numargs > 0 ? args[0] : "";
1091 while(*f)
1092 {
1093 int c = *f++;
1094 if(c == '%')
1095 {
1096 int i = *f++;
1097 bool twodigit = i == '0' && isdigit(f[0]) && isdigit(f[1]);
1098 if((i >= '1' && i <= '9') || twodigit)
1099 {
1100 if(twodigit) i = (f[0] - '0') * 10 + f[1] - '0', f += 2;
1101 else i -= '0';
1102 const char *sub = i < numargs ? args[i] : "";
1103 while(*sub) s.add(*sub++);
1104 }
1105 else s.add(i);
1106 }
1107 else s.add(c);
1108 }
1109 resultcharvector(s, 0);
1110}
1111COMMAND(format, "v");
1112
1113void format2(char **args, int numargs)

Callers 1

format2Function · 0.85

Calls 2

resultcharvectorFunction · 0.85
addMethod · 0.45

Tested by

no test coverage detected