I wanna do so this becomes:static struct super_block* sfs_get_super(struct file_system_type *fst, + int flags, const char *devname, void *data) { struct super_block *sb = 0; struct mounter_data_t *mount_data = sfs_get_mounter_data(dat +a); HIGHPRINT("Calling get_sb_single\n"); sb = get_sb_single(fst, flags, mount_data, sfs_fill_super); HIGHPRINT("Returned from get_sb_single\n"); dealloc_mounter_data(mount_data); return sb; }
That is, takes out the function and its arguments, and creates that skeleton documentation. I'm using Tie::File to read the file, and am currently halted on parsing the code. So far I've done this:/* Function: sfs_get_super(struct file_system_type *fst, int flags, co +nst char *devname, void *data) * * Parameters: * fst - * flags - * devname - * data - * * Returns: * struct super_block* */ static struct super_block* sfs_get_super(struct file_system_type *fst, + int flags, const char *devname, void *data) { struct super_block *sb = 0; struct mounter_data_t *mount_data = sfs_get_mounter_data(dat +a); HIGHPRINT("Calling get_sb_single\n"); sb = get_sb_single(fst, flags, mount_data, sfs_fill_super); HIGHPRINT("Returned from get_sb_single\n"); dealloc_mounter_data(mount_data); return sb; }
This only works with parsing one row (aka static int sfs_fill_super(struct super_block *sb, void *data, int silent) ), but its a start. { is always on a new line after the function (good old C coding style apparently :) ). I got tips to use C::Scan, but that that lacks documentation, and it seem to need some external application named "cppstdin". (Im using Windows here). So, I was wondering if anyone here had some smart way to solve this problem. I know there are some bright people here! ;)#!/usr/bin/perl # Script to add comments for Natural Doc. http://www.naturaldoc.org use Tie::File; use strict; use warnings; use Data::Dumper; my @FILE_ARRAY; tie @FILE_ARRAY, 'Tie::File', "searchfs.c", recsep => "\n" or die $!; my $found = 0; foreach (@FILE_ARRAY) { #if (/^(sub .+)/) { # Match .c function if (/^(?:([0-9_a-zA-Z*]+) +)?(?:([0-9_a-zA-Z*]+) +)?(?:([0-9_a-zA- +Z*]+) +)?([0-9_a-zA-Z*]+)\((.+?)\)/) { my ($a, $b, $c, $d, $e) = ("") x 5; if (defined($1)) { $a = $1; } if (defined($2)) { $b = $2; } if (defined($3)) { $c = $3; } if (defined($4)) { $d = $4; } if (defined($5)) { $e = $5; } print $a . " " . $b . " " . $c . " " . $d . " ARGS: " . $e . +"\n"; } }
In reply to Parsing C Source File Functions. by Ace128
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |