1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
|
From: Thomas Loimer <thomas.loimer@tuwien.ac.at>
Date: Sun, 5 Jan 2025 21:47:23 +0100
Origin: upstream, https://sourceforge.net/p/mcj/xfig/ci/d132132
Bug: https://sourceforge.net/p/mcj/tickets/183/
Forwarded: not-needed
Subject: Allow empty lines in comments, ticket #183
This partially reverts commit 0003887b.
--- a/src/f_read.c
+++ b/src/f_read.c
@@ -3,7 +3,7 @@
* Copyright (c) 1985-1988 by Supoj Sutanthavibul
* Parts Copyright (c) 1989-2015 by Brian V. Smith
* Parts Copyright (c) 1991 by Paul King
- * Parts Copyright (c) 2016-2024 by Thomas Loimer
+ * Parts Copyright (c) 2016-2025 by Thomas Loimer
*
* Any party obtaining a copy of these files is granted, free of charge, a
* full and unrestricted irrevocable, world-wide, paid up, royalty-free,
@@ -1632,14 +1632,11 @@ save_comment(void)
i = strlen(buf);
/* remove any newline */
- if (buf[i-1] == '\n') {
- buf[i-1] = '\0';
- --i;
- }
- /* buf contains at least '#'; return for "#" and "# " */
- if (i == 1 || (i == 2 && buf[1] == ' ')) {
+ if (buf[i-1] == '\n')
+ buf[--i] = '\0';
+ /* buf contains at least '#'; comment contains at least "# " */
+ if (i == 1)
return 1;
- }
/* see if we've allocated space for this comment */
if (comments[numcom])
free(comments[numcom]);
@@ -1647,10 +1644,7 @@ save_comment(void)
return -1;
/* remove one leading blank from the comment, if there is one */
- if (buf[1] == ' ')
- i = 2;
- else
- i = 1;
+ i = buf[1] == ' ' ? 2 : 1;
strcpy(comments[numcom++], &buf[i]);
return 1;
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -4,7 +4,7 @@
# Copyright (c) 1985-1988 by Supoj Sutanthavibul
# Parts Copyright (c) 1989-2015 by Brian V. Smith
# Parts Copyright (c) 1991 by Paul King
-# Parts Copyright (c) 2016-2019 by Thomas Loimer
+# Parts Copyright (c) 2016-2025 by Thomas Loimer
#
# Any party obtaining a copy of these files is granted, free of charge, a
# full and unrestricted irrevocable, world-wide, paid up, royalty-free,
@@ -16,7 +16,7 @@
# and this permission notice remain intact.
#
# atlocal.in
-# Author: Thomas Loimer, 2017-2019
+# Author: Thomas Loimer, 2017-2025
# use atlocal.in to pass variables from configure, that are
# AC_SUBST'ed in configure.ac, to the testsuite.
@@ -28,3 +28,4 @@ else
fi
PACKAGE_VERSION="@PACKAGE_VERSION@"
+SED='@SED@'
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -2,7 +2,7 @@ AT_COPYRIGHT([FIG : Facility for Interac
Copyright (c) 1985-1988 by Supoj Sutanthavibul
Parts Copyright (c) 1989-2015 by Brian V. Smith
Parts Copyright (c) 1991 by Paul King
-Parts Copyright (c) 2016-2024 by Thomas Loimer
+Parts Copyright (c) 2016-2025 by Thomas Loimer
Any party obtaining a copy of these files is granted, free of charge, a
full and unrestricted irrevocable, world-wide, paid up, royalty-free,
@@ -15,12 +15,23 @@ and this permission notice remain intact
])
# testsuite.at
-# Author: Thomas Loimer, 2016-2024
+# Author: Thomas Loimer, 2016-2025
AT_INIT
AT_COLOR_TESTS
AT_TESTED(xfig)
+m4_define([FIG_FILE_TOP], [#FIG 3.2
+#encoding: UTF-8
+Landscape
+Center
+Inches
+Letter
+100.
+Single
+-2
+1200 2])
+
AT_BANNER([Rudimentary tests])
AT_SETUP([Report version])
@@ -58,6 +69,7 @@ AT_SETUP([ignore too many comment lines,
AT_KEYWORDS([f_read.c])
AT_SKIP_IF([test x"$DISPLAY" = x])
AT_DATA(comments.fig, [#FIG 3.2
+#encoding: UTF-8
Landscape
Center
Inches
@@ -76,6 +88,25 @@ AT_CAPTURE_FILE([comments.fig])
AT_CAPTURE_FILE([comments.fig.bak])
AT_CLEANUP
+AT_SETUP([allow empty lines in comments, ticket #183])
+AT_KEYWORDS([f_read.c])
+AT_SKIP_IF([test x"$DISPLAY" = x])
+line_w_space='# '
+AT_DATA_UNQUOTED(empty.fig, [FIG_FILE_TOP
+# A comment
+$line_w_space
+# with an empty line.
+2 1 0 1 -1 -1 50 -1 -1 0.0 0 0 -1 0 0 2
+ 0 0 100 100
+])
+AT_CHECK([xfig -update empty.fig && \
+ $SED -n -e '/A comment/,/with an empty/ p' empty.fig.bak >orig && \
+ $SED -n -e '/A comment/,/with an empty/ p' empty.fig >new && \
+ diff orig new],0,[],ignore)
+AT_CAPTURE_FILE([empty.fig])
+AT_CAPTURE_FILE([empty.fig.bak])
+AT_CLEANUP
+
AT_BANNER([Unit tests])
# Skip these tests, if the linker does not understand the
|