From 59cc212ebe00245200e5a2d9f2393fbd1ddb4e94 Mon Sep 17 00:00:00 2001 From: jaortega Date: Sat, 10 Mar 2001 02:30:09 +0000 Subject: format fixings --- mixlib/mix_src_file.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) (limited to 'mixlib/mix_src_file.c') 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 #include #include #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++; } -- cgit v1.2.3