]> git.cameronkatri.com Git - bsdgames-darwin.git/commitdiff
fix bugs previously fixed. whee.
authorcgd <cgd@NetBSD.org>
Sat, 22 Apr 1995 09:59:01 +0000 (09:59 +0000)
committercgd <cgd@NetBSD.org>
Sat, 22 Apr 1995 09:59:01 +0000 (09:59 +0000)
quiz/quiz.c

index 00fff8177838f1b158ede55a326120309214d517..1d0b1d851aee3de601d88f806a6387117b53fd4c 100644 (file)
@@ -130,13 +130,13 @@ get_file(file)
        qp = &qlist;
        qsize = 0;
        while ((lp = fgetln(fp, &len)) != NULL) {
        qp = &qlist;
        qsize = 0;
        while ((lp = fgetln(fp, &len)) != NULL) {
+               lp[--len] = '\0';
                if (qp->q_text && qp->q_text[strlen(qp->q_text) - 1] == '\\')
                        qp->q_text = appdstr(qp->q_text, lp, len);
                else {
                        if ((qp->q_next = malloc(sizeof(QE))) == NULL)
                                err(1, NULL);
                        qp = qp->q_next;
                if (qp->q_text && qp->q_text[strlen(qp->q_text) - 1] == '\\')
                        qp->q_text = appdstr(qp->q_text, lp, len);
                else {
                        if ((qp->q_next = malloc(sizeof(QE))) == NULL)
                                err(1, NULL);
                        qp = qp->q_next;
-                       lp[len - 1] = '\0';
                        if ((qp->q_text = strdup(lp)) == NULL)
                                err(1, NULL);
                        qp->q_asked = qp->q_answered = FALSE;
                        if ((qp->q_text = strdup(lp)) == NULL)
                                err(1, NULL);
                        qp->q_asked = qp->q_answered = FALSE;
@@ -316,9 +316,10 @@ appdstr(s, tp, len)
        if ((m = malloc(strlen(s) + len + 1)) == NULL)
                err(1, NULL);
        for (mp = m, sp = s; *mp++ = *sp++;);
        if ((m = malloc(strlen(s) + len + 1)) == NULL)
                err(1, NULL);
        for (mp = m, sp = s; *mp++ = *sp++;);
-
+       --mp;
        if (*(mp - 1) == '\\')
                --mp;
        if (*(mp - 1) == '\\')
                --mp;
+
        while ((ch = *mp++ = *tp++) && ch != '\n');
        *mp = '\0';
 
        while ((ch = *mp++ = *tp++) && ch != '\n');
        *mp = '\0';