This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
length = strlen(orig);
if (start_offset < 0) start_offset += strlen(orig);
if (start_offset < 0 || start_offset > strlen(orig)) {
- ejsSetErrorMsg(eid, "substr arg 2 out of bounds");
+ ejsSetErrorMsg(eid, "substr arg 2 out of bounds ([%s], %d)", orig, start_offset);
return -1;
}
length = mprToInt(argv[2]);
if (length < 0) length += strlen(orig) - start_offset;
if (length < 0 || length+start_offset > strlen(orig)) {
- ejsSetErrorMsg(eid, "substr arg 3 out of bounds");
+ ejsSetErrorMsg(eid, "substr arg 3 out of bounds ([%s], %d, %d)", orig, start_offset, length);
return -1;
}
}
goto failed;
}
for (i=1;list[i];i++) {
- ret = talloc_asprintf_append(ret, "%s%s", separator, list[i]);
+ ret = talloc_asprintf_append_buffer(ret, "%s%s", separator, list[i]);
if (ret == NULL) {
goto failed;
}
ret = talloc_strdup(tmp_ctx, "");
/* avoid all the format string warnings */
- _asprintf_append = (_asprintf_append_t)talloc_asprintf_append;
+ _asprintf_append = (_asprintf_append_t)talloc_asprintf_append_buffer;
/*
hackity hack ...
char *fmt2;
int len, len_count=0;
char *tstr;
- ret = talloc_asprintf_append(ret, "%*.*s",
+ ret = talloc_asprintf_append_buffer(ret, "%*.*s",
(int)(p-format), (int)(p-format),
format);
if (ret == NULL) goto failed;
tstr--;
}
if (strcmp(tstr, "%") == 0) {
- ret = talloc_asprintf_append(ret, "%%");
+ ret = talloc_asprintf_append_buffer(ret, "%%");
if (ret == NULL) {
goto failed;
}
format += len+1;
}
- ret = talloc_asprintf_append(ret, "%s", format);
+ ret = talloc_asprintf_append_buffer(ret, "%s", format);
mpr_Return(eid, mprString(ret));
talloc_free(tmp_ctx);
return 0;
if (!isalnum(s[i])) count++;
}
- ret = talloc_size(mprMemCtx(), i + count*2 + 1);
+ ret = talloc_array(mprMemCtx(), char, i + count*2 + 1);
if (ret == NULL) {
return -1;
}
s = argv[0];
- ret = talloc_size(mprMemCtx(), strlen(s) + 1);
+ ret = talloc_array(mprMemCtx(), char, strlen(s) + 1);
if (ret == NULL) {
return -1;
}