Changeset 83745 in vbox for trunk/src/VBox/Runtime/win
- Timestamp:
- Apr 17, 2020 12:33:33 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 137266
- Location:
- trunk/src/VBox/Runtime/win
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/win/errmsgwin-sorter.cpp
r83744 r83745 85 85 86 86 87 /** 88 * Escapes @a pszString using @a pszBuf as needed. 89 * @note Duplicated in errmsg-sorter.cpp. 90 */ 91 static const char *EscapeString(const char *pszString, char *pszBuf, size_t cbBuf) 92 { 93 if (strpbrk(pszString, "\n\t\r\"\\") == NULL) 94 return pszString; 95 96 char *pszDst = pszBuf; 97 char ch; 98 do 99 { 100 ch = *pszString++; 101 switch (ch) 102 { 103 default: 104 *pszDst++ = ch; 105 break; 106 case '\\': 107 case '"': 108 *pszDst++ = '\\'; 109 *pszDst++ = ch; 110 break; 111 case '\n': 112 *pszDst++ = '\\'; 113 *pszDst++ = 'n'; 114 break; 115 case '\t': 116 *pszDst++ = '\\'; 117 *pszDst++ = 't'; 118 break; 119 case '\r': 120 break; /* drop it */ 121 } 122 } while (ch); 123 124 if ((uintptr_t)(pszDst - pszBuf) > cbBuf) 125 fprintf(stderr, "Escape buffer overrun!\n"); 126 127 return pszBuf; 128 } 129 130 87 131 int main(int argc, char **argv) 88 132 { … … 138 182 iPrev = pMsg->iCode; 139 183 140 /* Make sure the message string doesn't contain problematic characters: */141 const char *pszMsgFull = pMsg->pszMsgFull;142 if (strpbrk(pszMsgFull, "\"\\"))143 {144 char *pszDst = s_szMsgTmp;145 char ch;146 do147 {148 ch = *pszMsgFull++;149 if (ch == '\\' || ch == '"')150 *pszDst++ = '\\';151 *pszDst++ = ch;152 } while (ch);153 pszMsgFull = s_szMsgTmp;154 }155 156 184 /* Produce the output: */ 157 fprintf(pOut, "/*%#010lx:*/ { \"%s\", \"%s\", %ld },\n", 158 (unsigned long)pMsg->iCode, pszMsgFull, pMsg->pszDefine, pMsg->iCode);185 fprintf(pOut, "/*%#010lx:*/ { \"%s\", \"%s\", %ld },\n", (unsigned long)pMsg->iCode, 186 EscapeString(pMsg->pszMsgFull, s_szMsgTmp, sizeof(s_szMsgTmp)), pMsg->pszDefine, pMsg->iCode); 159 187 } 160 188 -
trunk/src/VBox/Runtime/win/errmsgwin.cpp
r83744 r83745 81 81 { 82 82 /* 83 * Perform binary search .83 * Perform binary search (duplicate code in RTErrGet). 84 84 */ 85 85 size_t iStart = 0;
Note:
See TracChangeset
for help on using the changeset viewer.