aboutsummaryrefslogtreecommitdiff
path: root/ch5/5-15_sort-fold.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ch5/5-15_sort-fold.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/ch5/5-15_sort-fold.c b/ch5/5-15_sort-fold.c
index 90b567b..90c658f 100644
--- a/ch5/5-15_sort-fold.c
+++ b/ch5/5-15_sort-fold.c
@@ -31,7 +31,6 @@ int istrcmp(const char *, const char *);
void my_qsort(void *v[], int left, int right, int (*comp)(const char *, const char *)) {
int i, last;
void swap(void *v[], int, int);
-
if (left >= right) {
return;
}
@@ -49,7 +48,6 @@ void my_qsort(void *v[], int left, int right, int (*comp)(const char *, const ch
int numcmp(const char *s1, const char *s2) {
double v1, v2;
-
v1 = atof(s1);
v2 = atof(s2);
if (v1 < v2) {
@@ -63,7 +61,6 @@ int numcmp(const char *s1, const char *s2) {
void swap(void *v[], int i, int j) {
void *temp;
-
temp = v[i];
v[i] = v[j];
v[j] = temp;
@@ -77,7 +74,7 @@ int readlines(char *lineptr[], int maxlines) {
if (nlines >= maxlines || (p = alloc(len)) == NULL) {
return -1;
} else {
- line[len-1] = '\0';
+ line[len - 1] = '\0';
strcpy(p, line);
lineptr[nlines++] = p;
}
@@ -104,7 +101,7 @@ void reverse_set(char *lineptr[], int nlines) {
/* Ignore character case, then send results to qsort */
int istrcmp(const char *s1, const char *s2) {
- for ( ; tolower(*s1) == tolower(*s2); s1++, s2++) {
+ for (; tolower(*s1) == tolower(*s2); s1++, s2++) {
if (*s1 == '\0') {
return 0;
}
@@ -135,18 +132,17 @@ char *alloc(int n) {
}
/* sort input lines */
-int main (int argc, char *argv[]) {
+int main(int argc, char *argv[]) {
int nlines; /* number of input lines read */
int numeric = 0; /* 1 if numeric sort */
int reverse = 0; /* 1 if reverse sort */
int fold = 0; /* 1 if folding upper and lower case */
-
if (argc > 1) {
int i, j;
for (i = 1, j = 0; --argc; i++) {
if (argv[i][j++] == '-') {
while (argv[i][j] != '\0') {
- switch(argv[i][j]) {
+ switch (argv[i][j]) {
case 'n':
numeric = 1;
break;