chiark
/
gitweb
/
~ian
/
chiark-tcl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
test-load targets: Use strip to sanitise whitespace in OTHER_DIRS so that the subst...
[chiark-tcl.git]
/
base
/
hook.c
diff --git
a/base/hook.c
b/base/hook.c
index e0b16d4fac762d7feb2ddb59948f63b89d7917be..6e4b3a102e4abe26cf48cdb26faad2066dd2d439 100644
(file)
--- a/
base/hook.c
+++ b/
base/hook.c
@@
-1,6
+1,6
@@
/*
* base code for various Tcl extensions
/*
* base code for various Tcl extensions
- * Copyright 2006 Ian Jackson
+ * Copyright 2006
-2012
Ian Jackson
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@
-13,9
+13,7
@@
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301, USA.
+ * along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include "chiark-tcl-base.h"
*/
#include "chiark-tcl-base.h"
@@
-53,11
+51,15
@@
void cht_obj_updatestr_vstringls(Tcl_Obj *o, ...) {
va_list al;
char *p;
const char *part;
va_list al;
char *p;
const char *part;
- int l, pl;
+ int l;
+ size_t pl;
va_start(al,o);
va_start(al,o);
- for (l=0; (part= va_arg(al, const char*)); )
- l+= va_arg(al, int);
+ for (l=0; (part= va_arg(al, const char*)); ) {
+ pl= va_arg(al, size_t);
+ assert(pl <= INT_MAX/2 - l);
+ l += pl;
+ }
va_end(al);
o->length= l;
va_end(al);
o->length= l;
@@
-65,7
+67,7
@@
void cht_obj_updatestr_vstringls(Tcl_Obj *o, ...) {
va_start(al,o);
for (p= o->bytes; (part= va_arg(al, const char*)); p += pl) {
va_start(al,o);
for (p= o->bytes; (part= va_arg(al, const char*)); p += pl) {
- pl= va_arg(al,
in
t);
+ pl= va_arg(al,
size_
t);
memcpy(p, part, pl);
}
va_end(al);
memcpy(p, part, pl);
}
va_end(al);
@@
-82,7
+84,7
@@
void cht_obj_updatestr_string(Tcl_Obj *o, const char *str) {
int cht_get_urandom(Tcl_Interp *ip, Byte *buffer, int l) {
static FILE *urandom;
int cht_get_urandom(Tcl_Interp *ip, Byte *buffer, int l) {
static FILE *urandom;
- int r
, esave
;
+ int r;
if (!urandom) {
urandom= fopen(URANDOM,"rb");
if (!urandom) {
urandom= fopen(URANDOM,"rb");
@@
-91,15
+93,14
@@
int cht_get_urandom(Tcl_Interp *ip, Byte *buffer, int l) {
r= fread(buffer,1,l,urandom);
if (r==l) return 0;
r= fread(buffer,1,l,urandom);
if (r==l) return 0;
- esave= errno;
- fclose(urandom); urandom=0;
-
if (ferror(urandom)) {
if (ferror(urandom)) {
- r
eturn
cht_posixerr(ip,errno,"read " URANDOM);
+ r
=
cht_posixerr(ip,errno,"read " URANDOM);
} else {
assert(feof(urandom));
} else {
assert(feof(urandom));
- r
eturn
cht_staticerr(ip, URANDOM " gave eof!", 0);
+ r
=
cht_staticerr(ip, URANDOM " gave eof!", 0);
}
}
+ fclose(urandom); urandom=0;
+ return r;
}
void cht_prepare__basic(Tcl_Interp *ip) {
}
void cht_prepare__basic(Tcl_Interp *ip) {