diff options
author | jaortega <jaortega> | 2001-03-10 02:30:09 +0000 |
---|---|---|
committer | jaortega <jaortega> | 2001-03-10 02:30:09 +0000 |
commit | 59cc212ebe00245200e5a2d9f2393fbd1ddb4e94 (patch) | |
tree | 74287c30c2e0dd630d98c4bc934fbacaf36f0679 /mixlib/mix_src_file.c | |
parent | c532202e4d9c4707cc8708b50607f246f359aac3 (diff) | |
download | mdk-59cc212ebe00245200e5a2d9f2393fbd1ddb4e94.tar.gz mdk-59cc212ebe00245200e5a2d9f2393fbd1ddb4e94.tar.bz2 |
format fixings
Diffstat (limited to 'mixlib/mix_src_file.c')
-rw-r--r-- | mixlib/mix_src_file.c | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/mixlib/mix_src_file.c b/mixlib/mix_src_file.c index b0e680b..1cb6656 100644 --- a/mixlib/mix_src_file.c +++ b/mixlib/mix_src_file.c @@ -1,7 +1,7 @@ /* -*-c-*- -------------- mix_src_file.c : * Implementation of the functions declared in mix_src_file.h * ------------------------------------------------------------------ - * Last change: Time-stamp: "01/02/16 00:03:10 jose" + * Last change: Time-stamp: "01/03/10 03:25:50 jose" * ------------------------------------------------------------------ * Copyright (C) 2000, 2001 Free Software Foundation, Inc. * @@ -21,6 +21,7 @@ * */ +#include <ctype.h> #include <stdio.h> #include <unistd.h> #include "mix_src_file.h" @@ -32,7 +33,48 @@ struct mix_src_file_t GPtrArray *lines; /* an array of the file lines */ guint lineno; /* the number of lines */ }; + +/* format a source line */ +static gchar * +format_line_ (gchar *line) +{ + const gchar *label, *op, *rest; + gint k = 0; + + if (!line) return line; + if (line[0] == '*' || strlen(line) == 0) return g_strdup (line); + + + if (isspace (line[0])) + { + label = " "; + while (line[k] && isspace (line[k])) ++k; + } + else + { + label = line; + while (line[k] && !isspace (line[k])) ++k; + while (line[k] && isspace (line[k])) ++k; + } + if (line[k]) + { + line[k - 1] = 0; + op = line + k; + while (line[k] && !isspace (line[k])) ++k; + while (line[k] && isspace (line[k])) ++k; + line[k - 1] = 0; + rest = (line[k]) ? line + k: "\n"; + } + else + { + op = rest = "\n"; + } + + + return g_strdup_printf ("%-12s%-6s%s", label, op, rest); +} + /* load the source file lines into memory */ static gboolean load_file_ (mix_src_file_t *file) @@ -51,7 +93,7 @@ load_file_ (mix_src_file_t *file) while (fgets (BUFFER, BUFFER_SIZE, f) == BUFFER) { - g_ptr_array_add (file->lines, (gpointer) g_strdup (BUFFER)); + g_ptr_array_add (file->lines, (gpointer) format_line_ (BUFFER)); file->lineno++; } |