[LON-CAPA-cvs] cvs: loncom /homework/caparesponse caparesponse.c
bowersj2
lon-capa-cvs@mail.lon-capa.org
Tue, 27 May 2003 15:29:02 -0000
bowersj2 Tue May 27 11:29:02 2003 EDT
Modified files:
/loncom/homework/caparesponse caparesponse.c
Log:
COMMIT BY GUY: Fix problem with later versions of SWIG passing NULL
instead of a pointer to an empty string.
Index: loncom/homework/caparesponse/caparesponse.c
diff -u loncom/homework/caparesponse/caparesponse.c:1.7 loncom/homework/caparesponse/caparesponse.c:1.8
--- loncom/homework/caparesponse/caparesponse.c:1.7 Tue Dec 4 10:17:57 2001
+++ loncom/homework/caparesponse/caparesponse.c Tue May 27 11:29:02 2003
@@ -1,6 +1,6 @@
/* The LearningOnline Network with CAPA
* CAPA wrapper code
- * $Id: caparesponse.c,v 1.7 2001/12/04 15:17:57 albertel Exp $
+ * $Id: caparesponse.c,v 1.8 2003/05/27 15:29:02 bowersj2 Exp $
*
* Copyright Michigan State University Board of Trustees
*
@@ -76,8 +76,7 @@
char *error=NULL,filename[FILE_NAME_LENGTH];
FILE *fp;
- /*fprintf(stderr,"hi in caparesponse\n");*/
- /*need to initialize unit parser*/
+ /* eed to initialize unit parser*/
sprintf(filename,"/home/httpd/html/res/adm/includes/capa.units");
if ((fp=fopen(filename,"r"))==NULL) {
/* printf("Error: can't open %s\n",filename);*/
@@ -104,16 +103,17 @@
p.tolerance = tolerance;
p.sig_lbound = sig_lbound;
p.sig_ubound = sig_ubound;
- strncpy(p.ans_fmt,ans_fmt,ANSWER_STRING_LENG-1);
- if (unit_str[0]!='\0') {
+
+ if (ans_fmt != NULL ) {
+ strncpy(p.ans_fmt,ans_fmt,ANSWER_STRING_LENG-1);
+ }
+ if (unit_str != NULL && unit_str[0]!='\0') {
strncpy(p.unit_str,unit_str,ANSWER_STRING_LENG-1);
p.ans_unit = u_parse_unit(unit_str);
} else {
p.unit_str[0]='\0';
- p.ans_unit=NULL;
}
p.calc = calc;
-
result=capa_check_answer(&p,response,&error);