*
* Copyright 2000 Bertho A. Stultiens (BS)
*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <windows.h>
// if(!cpdef)
// internal_error(__FILE__, __LINE__, "Codepage %d not found (vanished?)", cp);
// if((len = cp_wcstombs(cpdef, 0, uc, unistrlen(uc)+1, cptr, len+1, NULL, NULL)) < 0)
- if((len = WideCharToMultiByte(cp, 0, uc, unistrlen(uc)+1, cptr, len+1, NULL, NULL)) < 0)\r
+ if((len = WideCharToMultiByte(cp, 0, uc, unistrlen(uc)+1, cptr, len+1, NULL, NULL)) < 0)
+
internal_error(__FILE__, __LINE__, "Buffer overflow? code %d.", len);
return cptr;
}
case '\\': *cptr++ = '\\'; *cptr++ = '\\'; b += 2; break;
case '"': *cptr++ = '\\'; *cptr++ = '"'; b += 2; break;
default:
- n = sprintf(cptr, "\\x%04x", *uc & 0xffff);
+ n = sprintf(cptr, "\\x%04x", (unsigned)*uc & 0xffff);
cptr += n;
b += n;
}
}
else
{
- n = sprintf(cptr, "\\x%04x", *uc & 0xffff);
+ n = sprintf(cptr, "\\x%04x", (unsigned)*uc & 0xffff);
cptr += n;
b += n;
}
- if(i < len-1 && b >= 72)
+ if(i < len-1 && b >= 72 && cptr[-1] != '\\')
{
*cptr++ = '"';
*cptr++ = ',';
// assert(cpdef != NULL);
// if((i = cp_wcstombs(cpdef, 0, uc, unistrlen(uc)+1, tmp, 2*len+1, NULL, NULL)) < 0)
- if((i = WideCharToMultiByte(codepage, 0, uc, unistrlen(uc)+1, tmp, 2*len+1, NULL, NULL)) < 0)\r
+ if((i = WideCharToMultiByte(codepage, 0, uc, unistrlen(uc)+1, tmp, 2*len+1, NULL, NULL)) < 0)
+
internal_error(__FILE__, __LINE__, "Buffer overflow? code %d.", i);
*cptr++ = ' ';
*cptr++ = '"';
b += n;
}
}
- if(i < len-1 && b >= 72)
+ if(i < len-1 && b >= 72 && cptr[-1] != '\\')
{
*cptr++ = '"';
*cptr++ = ',';
}
-static char *make_bin_string(WCHAR *uc, int len, int *retlen, int codepage)\r
+static char *make_bin_string(WCHAR *uc, int len, int *retlen, int codepage)
+
{
char *str = xmalloc(7 * len + 1);
int i;