commit 86efd5ca1bbec536dc74d39dbae526c7dd8d0081
parent ee751029066ab7791856f1287724fee4bafeb988
Author: Kyle Milz <krwmilz@gmail.com>
Date: Tue, 14 Sep 2021 16:37:25 +0000
move atopix() into only source file that uses it
Diffstat:
M | special.c | | | 40 | ++++++++++++++++++++++++++++++++++++++++ |
M | xdvi.c | | | 39 | --------------------------------------- |
M | xdvi.h | | | 3 | --- |
3 files changed, 40 insertions(+), 42 deletions(-)
diff --git a/special.c b/special.c
@@ -963,6 +963,46 @@ color_special(cp)
}
+static int
+atopix(const char *arg, Boolean allow_minus)
+{
+ int len = strlen(arg);
+ const char *arg_end = arg;
+ char tmp[11];
+ double factor;
+
+ if (allow_minus && *arg_end == '-') ++arg_end;
+ while ((*arg_end >= '0' && *arg_end <= '9') || *arg_end == '.')
+ if (arg_end >= arg + XtNumber(tmp) - 1) return 0;
+ else ++arg_end;
+ bcopy(arg, tmp, arg_end - arg);
+ tmp[arg_end - arg] = '\0';
+
+#if A4
+ factor = 1.0 / 2.54; /* cm */
+#else
+ factor = 1.0; /* inches */
+#endif
+ if (len > 2)
+ switch (arg[len - 2] << 8 | arg[len - 1]) {
+#if A4
+ case 'i' << 8 | 'n': factor = 1.0; break;
+#else
+ case 'c' << 8 | 'm': factor = 1.0 / 2.54; break;
+#endif
+ case 'm' << 8 | 'm': factor = 1.0 / 25.4; break;
+ case 'p' << 8 | 't': factor = 1.0 / 72.27; break;
+ case 'p' << 8 | 'c': factor = 12.0 / 72.27; break;
+ case 'b' << 8 | 'p': factor = 1.0 / 72.0; break;
+ case 'd' << 8 | 'd': factor = 1238.0 / 1157.0 / 72.27; break;
+ case 'c' << 8 | 'c': factor = 12 * 1238.0 / 1157.0 / 72.27;
+ break;
+ case 's' << 8 | 'p': factor = 1.0 / 72.27 / 65536; break;
+ }
+
+ return (int) (factor * atof(tmp) * pixels_per_inch + 0.5);
+}
+
static unsigned int
myatopix(pp)
diff --git a/xdvi.c b/xdvi.c
@@ -348,45 +348,6 @@ usage(const char *message, ...)
exit(1);
}
-int
-atopix(const char *arg, Boolean allow_minus)
-{
- int len = strlen(arg);
- const char *arg_end = arg;
- char tmp[11];
- double factor;
-
- if (allow_minus && *arg_end == '-') ++arg_end;
- while ((*arg_end >= '0' && *arg_end <= '9') || *arg_end == '.')
- if (arg_end >= arg + XtNumber(tmp) - 1) return 0;
- else ++arg_end;
- bcopy(arg, tmp, arg_end - arg);
- tmp[arg_end - arg] = '\0';
-
-#if A4
- factor = 1.0 / 2.54; /* cm */
-#else
- factor = 1.0; /* inches */
-#endif
- if (len > 2)
- switch (arg[len - 2] << 8 | arg[len - 1]) {
-#if A4
- case 'i' << 8 | 'n': factor = 1.0; break;
-#else
- case 'c' << 8 | 'm': factor = 1.0 / 2.54; break;
-#endif
- case 'm' << 8 | 'm': factor = 1.0 / 25.4; break;
- case 'p' << 8 | 't': factor = 1.0 / 72.27; break;
- case 'p' << 8 | 'c': factor = 12.0 / 72.27; break;
- case 'b' << 8 | 'p': factor = 1.0 / 72.0; break;
- case 'd' << 8 | 'd': factor = 1238.0 / 1157.0 / 72.27; break;
- case 'c' << 8 | 'c': factor = 12 * 1238.0 / 1157.0 / 72.27;
- break;
- case 's' << 8 | 'p': factor = 1.0 / 72.27 / 65536; break;
- }
-
- return (int) (factor * atof(tmp) * pixels_per_inch + 0.5);
-}
/**
** Main program starts here.
diff --git a/xdvi.h b/xdvi.h
@@ -185,7 +185,4 @@ char *ffline = NULL; /* an array used by filefind to store */
/* Also used elsewhere. */
size_t ffline_len = 0; /* current length of ffline[] */
-
-extern int atopix(const char *, Boolean);
-
#endif /* XDVI_H */