[m-rev.] diff: cleanup mkinit.c

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon May 2 11:44:09 AEST 2005


util/mkinit.c:
	Convert this file to four-space indentation to eliminate bad line
	breaks, and update it to make it conform to our coding conventions.

Zoltan.

cvs diff: Diffing .
Index: mkinit.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/util/mkinit.c,v
retrieving revision 1.96
diff -u -b -r1.96 mkinit.c
--- mkinit.c	15 Feb 2005 05:22:40 -0000	1.96
+++ mkinit.c	30 Apr 2005 05:09:26 -0000
@@ -1,5 +1,7 @@
 /*---------------------------------------------------------------------------*/
-
+/*
+** vim:sw=4 ts=4 expandtab
+*/
 /*
 ** Copyright (C) 1995-2005 The University of Melbourne.
 ** This file may only be copied under the terms of the GNU General
@@ -549,8 +551,10 @@
 			break;
 
 		case 'c':
-			if (sscanf(optarg, "%d", &maxcalls) != 1)
+            if (sscanf(optarg, "%d", &maxcalls) != 1) {
 				usage();
+            }
+
 			break;
 
 		case 'g':
@@ -566,11 +570,9 @@
 			** Add the directory name to the end of the
 			** search path for `.init' files.
 			*/
-			tmp_slist = (String_List *)
-				checked_malloc(sizeof(String_List));
+            tmp_slist = (String_List *) checked_malloc(sizeof(String_List));
 			tmp_slist->next = NULL;
-			tmp_slist->data = (char *)
-				checked_malloc(strlen(optarg) + 1);
+            tmp_slist->data = (char *) checked_malloc(strlen(optarg) + 1);
 			strcpy(tmp_slist->data, optarg);
 			*init_file_dirs_tail = tmp_slist;
 			init_file_dirs_tail = &tmp_slist->next;
@@ -590,15 +592,13 @@
 
 		case 'r':
 			/*
-			** Add the directory name to the end of the
-			** search path for `.init' files.
+            ** Add the argument to the end of the list of runtime flags.
 			*/
 			if (optarg[0] != '\0') {
 				tmp_slist = (String_List *)
 					checked_malloc(sizeof(String_List));
 				tmp_slist->next = NULL;
-				tmp_slist->data = (char *)
-					checked_malloc(strlen(optarg) + 1);
+                tmp_slist->data = (char *) checked_malloc(strlen(optarg) + 1);
 				strcpy(tmp_slist->data, optarg);
 				*runtime_flags_tail = tmp_slist;
 				runtime_flags_tail = &tmp_slist->next;
@@ -638,9 +638,19 @@
 static void
 usage(void)
 {
-	fprintf(stderr,
-"Usage: mkinit [options] files...\n"
-"Options: [-a] [-c maxcalls] [-o filename] [-w entry] [-i] [-l] [-t] [-x]\n");
+    fputs("Usage: mkinit [options] files...\n", stderr);
+    fputs("Options:\n", stderr);
+    fputs("  -a:\t\tenable Aditi\n", stderr);
+    fputs("  -c maxcalls:\tset the max size of an init function\n", stderr);
+    fputs("  -g grade:\tset the grade of the executable\n", stderr);
+    fputs("  -i:\t\tenable initialization code\n", stderr);
+    fputs("  -l:\t\tdo not output main function\n", stderr);
+    fputs("  -o file:\toutput to the named file\n", stderr);
+    fputs("  -r word:\tadd word to the flags for the runtime\n", stderr);
+    fputs("  -t:\t\tenable execution tracing\n", stderr);
+    fputs("  -w entry:\tset the entry point to the egiven label\n", stderr);
+    fputs("  -x:\t\tscan the C files for extra initializations\n", stderr);
+    fputs("  -I dir:\tadd dir to the search path for init files\n", stderr);
 	exit(EXIT_FAILURE);
 }
 
@@ -670,9 +680,9 @@
 /*---------------------------------------------------------------------------*/
 
 /*
-** Scan the list of files for ones not found in the current
-** directory, and replace them with their full path equivalent
-** if they are found in the list of search directories.
+** Scan the list of files for ones not found in the current directory,
+** and replace them with their full path equivalent if they are found
+** in the list of search directories.
 */
 
 static void
@@ -683,9 +693,10 @@
 
 	for (filenum = 0; filenum < num_files; filenum++) {
 		init_file = find_init_file(files[filenum]);
-		if (init_file != NULL)
+        if (init_file != NULL) {
 			files[filenum] = init_file;
 	}
+    }
 }
 
 /*
@@ -693,6 +704,7 @@
 ** If the file is in the current directory or is not in any of the
 ** search directories, then return NULL.  Otherwise return the full
 ** path name to the file.
+**
 ** It is the caller's responsibility to free the returned buffer
 ** holding the full path name when it is no longer needed.
 */
@@ -714,9 +726,7 @@
 
 	baselen = strlen(base_name);
 
-	for (dir_ptr = init_file_dirs; dir_ptr != NULL;
-		dir_ptr = dir_ptr->next)
-	{
+    for (dir_ptr = init_file_dirs; dir_ptr != NULL; dir_ptr = dir_ptr->next) {
 		dirname = dir_ptr->data;
 		dirlen = strlen(dirname);
 		len = dirlen + 1 + baselen;
@@ -832,8 +842,7 @@
 	printf("\nMR_ComplexityProc MR_complexity_proc_table[] = {\n");
 
 	num_experimental_complexity_procs = 0;
-	while ((procname = read_line(filename, fp, MAX_PROCNAME_LEN)) != NULL)
-	{
+    while ((procname = read_line(filename, fp, MAX_PROCNAME_LEN)) != NULL) {
 		num_experimental_complexity_procs++;
 		output_complexity_proc(procname);
 	}
@@ -881,8 +890,8 @@
 	num_bunches = 0;
 	num_calls_in_cur_bunch = 0;
 	for (filenum = 0; filenum < num_files; filenum++) {
-		process_file(files[filenum],
-			&num_bunches, &num_calls_in_cur_bunch, purpose);
+        process_file(files[filenum], &num_bunches,
+            &num_calls_in_cur_bunch, purpose);
 	}
 
 	fputs("}\n", stdout);
@@ -954,8 +963,7 @@
 		aditi_load_func, hl_entry_point, entry_point);
 
 	printf("	MR_runtime_flags = \"");
-	for (list_tmp = runtime_flags;
-		list_tmp != NULL; list_tmp = list_tmp->next)
+    for (list_tmp = runtime_flags; list_tmp != NULL; list_tmp = list_tmp->next)
 	{
 		for (options_str = list_tmp->data;
 			*options_str != '\0'; options_str++)
@@ -1085,13 +1093,11 @@
 		int	mercury_len;
 
 		mercury_len = strlen("mercury__");
-		module_name_size =
-			strlen(func_name) - mercury_len - strlen("__");
+        module_name_size = strlen(func_name) - mercury_len - strlen("__");
 		rl_data_name = checked_malloc(module_name_size +
 			strlen(aditi_rl_data_str) + 1);
 		strcpy(rl_data_name, aditi_rl_data_str);
-		strncat(rl_data_name, func_name + mercury_len,
-			module_name_size);
+        strncat(rl_data_name, func_name + mercury_len, module_name_size);
 		add_rl_data(rl_data_name);
 	}
 }
@@ -1125,17 +1131,14 @@
 			int	j;
 			MR_bool	special;
 
-			for (j = init_strlen;
-				MR_isalnum(line[j]) || line[j] == '_'; j++)
-			{
+            for (j = init_strlen; MR_isalnum(line[j]) || line[j] == '_'; j++) {
 				/* VOID */
 			}
 			line[j] = '\0';
 
 			func_name = line + init_strlen;
 			func_name_len = strlen(func_name);
-			if (MR_strneq(&func_name[func_name_len - 4], "init", 4))
-			{
+            if (MR_strneq(&func_name[func_name_len - 4], "init", 4)) {
 				func_name[func_name_len - 4] = '\0';
 				special = MR_FALSE;
 			} else {
@@ -1183,8 +1186,7 @@
 
 static void
 output_init_function(const char *func_name, int *num_bunches_ptr,
-	int *num_calls_in_cur_bunch_ptr, Purpose purpose,
-	MR_bool special_module)
+    int *num_calls_in_cur_bunch_ptr, Purpose purpose, MR_bool special_module)
 {
 	if (purpose == PURPOSE_DEBUGGER) {
 		if (special_module) {
@@ -1368,7 +1370,8 @@
 {
 	void	*mem;
 
-	if ((mem = malloc(size)) == NULL) {
+    mem = malloc(size);
+    if (mem == NULL) {
 		fprintf(stderr, "Out of memory\n");
 		exit(EXIT_FAILURE);
 	}
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list