History

Revert back to always compiling internal getopt but now manually rename all referenced symbols instead of using unsafe #defines to do that same job.

cbagwell committed 17 years ago

Commit 8025dd71 parent 38208db16 files · +191 −198Browse files

Showing the changes to src/spectrogram.c (1 of 16 files). Show all

Unified · Split

src/spectrogram.c+7−11
@@ -26,15 +26,11 @@ · 25 unmodified lines
2626
2727 #include "sox_i.h"
2828 #include "fft4g.h"
29+#include "sgetopt.h"
2930 #include <assert.h>
3031 #include <math.h>
3132 #include <png.h>
3233
33−/* we are playing games with getopt aliases so this needs to be included
34− * after system header files to prevent aliasing OS's version of getopt.
35− */
36−#include "getopt.h"
37−
3834 #define malloc lsx_malloc
3935 #define calloc lsx_calloc
4036 #define realloc lsx_realloc
@@ -89,7 +85,7 @@ static int getopts(sox_effect_t * effp, int argc, char **argv) · 48 unmodified lines
8985 p->spectrum_points = 249, p->perm = 1, p->max_cols = MAX_COLS;
9086 p->out_name = "spectrogram.png", p->comment = "Created by SoX";
9187
92− while ((c = getopt(argc, argv, "+M:x:X:y:z:Z:q:p:w:st:c:amlho:")) != -1) switch (c) {
88+ while ((c = lsx_getopt(argc, argv, "+M:x:X:y:z:Z:q:p:w:st:c:amlho:")) != -1) switch (c) {
9389 GETOPT_NUMERIC('M', max_cols , 100, 2000)
9490 GETOPT_NUMERIC('x', pixels_per_sec, 1 , 5000)
9591 GETOPT_NUMERIC('y', y_size , 1 , 1 + MAX_DFT_SIZE_SHIFT)
@@ -100,25 +96,25 @@ static int getopts(sox_effect_t * effp, int argc, char **argv) · 4 unmodified lines
10096 case 'w': p->win_type = lsx_enum_option(c, window_options); break;
10197 case 's': p->slack_overlap = sox_true; break;
10298 case 'X':
103− next = lsx_parsesamples(1e5, optarg, &duration_1e5, 't');
99+ next = lsx_parsesamples(1e5, lsx_optarg, &duration_1e5, 't');
104100 if (next == NULL || *next != '\0' || duration_1e5 > p->max_cols * 1e5
105101 || duration_1e5 < 1e5 / 5000 * p->max_cols)
106102 return lsx_usage(effp);
107103 p->pixels_per_sec = p->max_cols * 1e5 / duration_1e5;
108104 break;
109− case 't': p->title = optarg; break;
110− case 'c': p->comment = optarg; break;
105+ case 't': p->title = lsx_optarg; break;
106+ case 'c': p->comment = lsx_optarg; break;
111107 case 'a': p->no_axes = sox_true; break;
112108 case 'm': p->monochrome = sox_true; break;
113109 case 'l': p->light_background = sox_true; break;
114110 case 'h': p->high_colour = sox_true; break;
115− case 'o': p->out_name = optarg; break;
111+ case 'o': p->out_name = lsx_optarg; break;
116112 default: lsx_fail("invalid option `-%c'", optopt); return lsx_usage(effp);
117113 }
118114 p->gain = -p->gain;
119115 --p->y_size, --p->perm;
120116 p->spectrum_points += 2;
121− return optind !=argc || p->win_type == INT_MAX? lsx_usage(effp) : SOX_SUCCESS;
117+ return lsx_optind !=argc || p->win_type == INT_MAX? lsx_usage(effp) : SOX_SUCCESS;
122118 }
123119
124120 static double make_window(priv_t * p, int end)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t