Code style fixes.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12799 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
parent
b5effef746
commit
551f00ac47
|
@ -99,7 +99,7 @@ typedef enum {
|
|||
osalSysLockFromISR(); \
|
||||
osalThreadResumeI(&(i2cp)->thread, MSG_OK); \
|
||||
osalSysUnlockFromISR(); \
|
||||
} while(0)
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* @brief Wakes up the waiting thread notifying errors.
|
||||
|
@ -112,7 +112,7 @@ typedef enum {
|
|||
osalSysLockFromISR(); \
|
||||
osalThreadResumeI(&(i2cp)->thread, MSG_RESET); \
|
||||
osalSysUnlockFromISR(); \
|
||||
} while(0)
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* @brief Wrap i2cMasterTransmitTimeout function with TIME_INFINITE timeout.
|
||||
|
|
|
@ -64,7 +64,6 @@ typedef struct hal_trng_driver TRNGDriver;
|
|||
*/
|
||||
typedef struct hal_trng_config TRNGConfig;
|
||||
|
||||
|
||||
/* Including the low level driver header, it exports information required
|
||||
for completing types.*/
|
||||
#include "hal_trng_lld.h"
|
||||
|
|
|
@ -324,7 +324,7 @@ msg_t dacConvert(DACDriver *dacp,
|
|||
void dacAcquireBus(DACDriver *dacp) {
|
||||
|
||||
osalDbgCheck(dacp != NULL);
|
||||
|
||||
|
||||
osalMutexLock(&dacp->mutex);
|
||||
}
|
||||
|
||||
|
@ -340,7 +340,7 @@ void dacAcquireBus(DACDriver *dacp) {
|
|||
void dacReleaseBus(DACDriver *dacp) {
|
||||
|
||||
osalDbgCheck(dacp != NULL);
|
||||
|
||||
|
||||
osalMutexUnlock(&dacp->mutex);
|
||||
}
|
||||
#endif /* DAC_USE_MUTUAL_EXCLUSION == TRUE */
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
* @brief Waits until the current erase operation is finished.
|
||||
*
|
||||
* @param[in] devp pointer to a @p BaseFlash object
|
||||
*
|
||||
*
|
||||
* @return An error code.
|
||||
* @retval FLASH_NO_ERROR if there is no erase operation in progress.
|
||||
* @retval FLASH_ERROR_ERASE if the erase operation failed.
|
||||
|
|
|
@ -600,7 +600,6 @@ msg_t oqGetI(output_queue_t *oqp) {
|
|||
return MSG_TIMEOUT;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Output queue non-blocking write.
|
||||
* @details The function writes data from a buffer to an output queue. The
|
||||
|
|
|
@ -695,7 +695,7 @@ bool sdcConnect(SDCDriver *sdcp) {
|
|||
goto failed;
|
||||
}
|
||||
|
||||
if(sdc_lld_read_special(sdcp, ext_csd, 512, MMCSD_CMD_SEND_EXT_CSD, 0)) {
|
||||
if (sdc_lld_read_special(sdcp, ext_csd, 512, MMCSD_CMD_SEND_EXT_CSD, 0)) {
|
||||
goto failed;
|
||||
}
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ static msg_t _ctl(void *ip, unsigned int operation, void *arg) {
|
|||
default:
|
||||
#if defined(SDU_LLD_IMPLEMENTS_CTL)
|
||||
/* The SDU driver does not have a LLD but the application can use this
|
||||
hook to implement extra controls by supplying this function.*/
|
||||
hook to implement extra controls by supplying this function.*/
|
||||
extern msg_t sdu_lld_control(SerialUSBDriver *sdup,
|
||||
unsigned int operation,
|
||||
void *arg);
|
||||
|
@ -310,7 +310,7 @@ void sduStop(SerialUSBDriver *sdup) {
|
|||
void sduSuspendHookI(SerialUSBDriver *sdup) {
|
||||
|
||||
/* Avoiding events spam.*/
|
||||
if(bqIsSuspendedX(&sdup->ibqueue) && bqIsSuspendedX(&sdup->obqueue)) {
|
||||
if (bqIsSuspendedX(&sdup->ibqueue) && bqIsSuspendedX(&sdup->obqueue)) {
|
||||
return;
|
||||
}
|
||||
chnAddFlagsI(sdup, CHN_DISCONNECTED);
|
||||
|
|
|
@ -147,7 +147,7 @@ void uartStop(UARTDriver *uartp) {
|
|||
void uartStartSend(UARTDriver *uartp, size_t n, const void *txbuf) {
|
||||
|
||||
osalDbgCheck((uartp != NULL) && (n > 0U) && (txbuf != NULL));
|
||||
|
||||
|
||||
osalSysLock();
|
||||
osalDbgAssert(uartp->state == UART_READY, "is active");
|
||||
osalDbgAssert(uartp->txstate != UART_TX_ACTIVE, "tx active");
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
* @init
|
||||
*/
|
||||
void wdgInit(void) {
|
||||
|
||||
|
||||
wdg_lld_init();
|
||||
}
|
||||
|
||||
|
|
|
@ -107,7 +107,6 @@ typedef enum {
|
|||
/* Dummy configuration, it is not needed.*/ \
|
||||
uint32_t dummy
|
||||
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
/*===========================================================================*/
|
||||
|
|
|
@ -185,7 +185,6 @@ typedef uint32_t iopadid_t;
|
|||
(void)bits; \
|
||||
} while (false)
|
||||
|
||||
|
||||
/**
|
||||
* @brief Sets a bits mask on a I/O port.
|
||||
* @note The @ref PAL provides a default software implementation of this
|
||||
|
@ -203,7 +202,6 @@ typedef uint32_t iopadid_t;
|
|||
(void)bits; \
|
||||
} while (false)
|
||||
|
||||
|
||||
/**
|
||||
* @brief Clears a bits mask on a I/O port.
|
||||
* @note The @ref PAL provides a default software implementation of this
|
||||
|
@ -221,7 +219,6 @@ typedef uint32_t iopadid_t;
|
|||
(void)bits; \
|
||||
} while (false)
|
||||
|
||||
|
||||
/**
|
||||
* @brief Toggles a bits mask on a I/O port.
|
||||
* @note The @ref PAL provides a default software implementation of this
|
||||
|
@ -239,7 +236,6 @@ typedef uint32_t iopadid_t;
|
|||
(void)bits; \
|
||||
} while (false)
|
||||
|
||||
|
||||
/**
|
||||
* @brief Reads a group of bits.
|
||||
* @note The @ref PAL provides a default software implementation of this
|
||||
|
@ -348,7 +344,6 @@ typedef uint32_t iopadid_t;
|
|||
(void)pad; \
|
||||
} while (false)
|
||||
|
||||
|
||||
/**
|
||||
* @brief Clears a pad logical state to @p PAL_LOW.
|
||||
* @note The @ref PAL provides a default software implementation of this
|
||||
|
@ -366,7 +361,6 @@ typedef uint32_t iopadid_t;
|
|||
(void)pad; \
|
||||
} while (false)
|
||||
|
||||
|
||||
/**
|
||||
* @brief Toggles a pad logical state.
|
||||
* @note The @ref PAL provides a default software implementation of this
|
||||
|
@ -384,7 +378,6 @@ typedef uint32_t iopadid_t;
|
|||
(void)pad; \
|
||||
} while (false)
|
||||
|
||||
|
||||
/**
|
||||
* @brief Pad mode setup.
|
||||
* @details This function programs a pad with the specified mode.
|
||||
|
|
|
@ -152,7 +152,7 @@ void sdc_lld_set_bus_mode(SDCDriver *sdcp, sdcbusmode_t mode) {
|
|||
|
||||
break;
|
||||
case SDC_MODE_4BIT:
|
||||
|
||||
|
||||
break;
|
||||
case SDC_MODE_8BIT:
|
||||
|
||||
|
|
|
@ -90,7 +90,6 @@ void sd_lld_start(SerialDriver *sdp, const SerialConfig *config) {
|
|||
config = &default_config;
|
||||
}
|
||||
|
||||
|
||||
if (sdp->state == SD_STOP) {
|
||||
#if PLATFORM_SERIAL_USE_USART1 == TRUE
|
||||
if (&SD1 == sdp) {
|
||||
|
|
|
@ -58,7 +58,6 @@
|
|||
#define MSG_RESET (msg_t)-2
|
||||
/** @} */
|
||||
|
||||
|
||||
/**
|
||||
* @name Special time constants
|
||||
* @{
|
||||
|
|
|
@ -160,7 +160,6 @@ typedef uint32_t time_conv_t;
|
|||
/* Module macros. */
|
||||
/*===========================================================================*/
|
||||
|
||||
|
||||
/**
|
||||
* @name Fast time conversion utilities
|
||||
* @{
|
||||
|
|
|
@ -45,9 +45,9 @@
|
|||
"be zero or greater than one"
|
||||
#endif
|
||||
|
||||
//#if (CH_CFG_ST_TIMEDELTA > 0) && (CH_CFG_TIME_QUANTUM > 0)
|
||||
//#error "CH_CFG_TIME_QUANTUM not supported in tickless mode"
|
||||
//#endif
|
||||
#if (CH_CFG_ST_TIMEDELTA > 0) && (CH_CFG_TIME_QUANTUM > 0)
|
||||
#error "CH_CFG_TIME_QUANTUM not supported in tickless mode"
|
||||
#endif
|
||||
|
||||
#if (CH_CFG_ST_TIMEDELTA > 0) && (CH_DBG_THREADS_PROFILING == TRUE)
|
||||
#error "CH_DBG_THREADS_PROFILING not supported in tickless mode"
|
||||
|
|
|
@ -74,6 +74,8 @@
|
|||
*****************************************************************************
|
||||
|
||||
*** Next ***
|
||||
- NEW: Lots of style fixes thanks to the new tool.
|
||||
- NEW: Code style checker tool added.
|
||||
- NEW: Added and embedded flash driver model in HAL. Added an implementation
|
||||
for STM32F1xx, STM32L4xx, STM32L4xx+.
|
||||
- NEW: Modified AES GCM function signatures.
|
||||
|
|
|
@ -1,172 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
use strict;
|
||||
use warnings;
|
||||
use File::Basename;
|
||||
|
||||
# Desired indentation.
|
||||
my $indentation = 2;
|
||||
|
||||
if ($#ARGV != 0) {
|
||||
print "\nUsage: simplecheck.pl source\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
my $source = $ARGV[0];
|
||||
|
||||
open(my $in, "<", $source) or die "Can't open source: $!";
|
||||
|
||||
my $lineno = 0;
|
||||
my @c_source = <$in>;
|
||||
my $filename = $source;
|
||||
$filename =~ y/\\/\//;
|
||||
$filename = basename($filename);
|
||||
|
||||
my $cr = "\r";
|
||||
my $lf = "\n";
|
||||
my $tab = "\t";
|
||||
my $c_comment = "";
|
||||
my $state = "start";
|
||||
|
||||
sub style {
|
||||
my $desc = shift;
|
||||
|
||||
print("style: $desc at line $lineno in \"$filename\"\n");
|
||||
}
|
||||
|
||||
sub error {
|
||||
my $desc = shift;
|
||||
|
||||
print("error: $desc at line $lineno in \"$filename\"\n");
|
||||
}
|
||||
|
||||
my $emptycnt = 0;
|
||||
foreach my $line (@c_source) {
|
||||
|
||||
$lineno += 1;
|
||||
|
||||
#****************************************************************************
|
||||
# Check on EOL.
|
||||
if (not ($line =~ /$cr$lf$/)) {
|
||||
error "detected malformed EOL";
|
||||
}
|
||||
$line =~ s/$cr//;
|
||||
$line =~ s/$lf//;
|
||||
|
||||
#****************************************************************************
|
||||
# Check on trailing spaces.
|
||||
if ($line =~ /\s$/) {
|
||||
style "detected trailing spaces";
|
||||
}
|
||||
|
||||
#****************************************************************************
|
||||
# Check on TABs.
|
||||
if ($line =~ /$tab/) {
|
||||
style "detected TAB";
|
||||
$line =~ s/$tab/ /;
|
||||
}
|
||||
|
||||
#****************************************************************************
|
||||
# Check on empty lines.
|
||||
my $tmp = $line;
|
||||
$tmp =~ s/\s//;
|
||||
if (length($tmp) == 0) {
|
||||
$emptycnt = $emptycnt + 1;
|
||||
if ($emptycnt == 2) {
|
||||
style "detected multiple empty lines"
|
||||
}
|
||||
next;
|
||||
}
|
||||
else {
|
||||
$emptycnt = 0;
|
||||
}
|
||||
|
||||
#******************************************************************************
|
||||
# State machine handling.
|
||||
if ($state eq "start") {
|
||||
|
||||
#******************************************************************************
|
||||
# Comment start matching.
|
||||
if ("$line" =~ /^\s*\/\*/) {
|
||||
if ("$line" =~ /\*\//) {
|
||||
# Special case of single line comments.
|
||||
$line =~ /^\s*(\/\*.*\*\/)/;
|
||||
}
|
||||
else {
|
||||
# Start of multi-line comment.
|
||||
$line =~ /(\/\*.*)/;
|
||||
$c_comment = $1 . " ";
|
||||
$state = "incomment";
|
||||
}
|
||||
}
|
||||
else {
|
||||
#****************************************************************************
|
||||
# Check on loose semicolons.
|
||||
if ($line =~ /\s;/) {
|
||||
style "detected loose semicolon";
|
||||
}
|
||||
|
||||
#****************************************************************************
|
||||
# Check on glued keywords.
|
||||
if ($line =~ /if\(/) {
|
||||
style "detected glued \"if\"";
|
||||
}
|
||||
if ($line =~ /for\(/) {
|
||||
style "detected glued \"for\"";
|
||||
}
|
||||
if ($line =~ /while\(/) {
|
||||
style "detected glued \"while\"";
|
||||
}
|
||||
if ($line =~ /switch\(/) {
|
||||
style "detected glued \"switch\"";
|
||||
}
|
||||
if ($line =~ /do\{/) {
|
||||
style "detected glued \"do\"";
|
||||
}
|
||||
|
||||
#****************************************************************************
|
||||
# Check on loose parenthesis.
|
||||
if ($line =~ /\(\s+/) {
|
||||
style "detected loose \"(\"";
|
||||
}
|
||||
if ($line =~ /\s+\)/) {
|
||||
style "detected loose \")\"";
|
||||
}
|
||||
|
||||
#****************************************************************************
|
||||
# Check on glued braces.
|
||||
if ($line =~ /\)\{/) {
|
||||
style "detected glued left brace";
|
||||
}
|
||||
if ($line =~ /\w\{/) {
|
||||
style "detected glued left brace";
|
||||
}
|
||||
if ($line =~ /\}\w/) {
|
||||
style "detected glued right brace";
|
||||
}
|
||||
|
||||
#****************************************************************************
|
||||
# Check function-call-like returns.
|
||||
if ($line =~ /return\s*\(/) {
|
||||
style "detected function-call-like return";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#******************************************************************************
|
||||
# Scanning for comment end.
|
||||
elsif ($state eq "incomment") {
|
||||
if ("$line" =~ /\*\/\s*$/) {
|
||||
# End of mult-line comment.
|
||||
$line =~ /(.*\*\/)/;
|
||||
$c_comment .= $1;
|
||||
|
||||
$state = "start";
|
||||
}
|
||||
else {
|
||||
# Add the whole line.
|
||||
$c_comment .= $line . " ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close $in or die "$in: $!";
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
find ../../os/rt -name "*.[ch]" -exec perl stylecheck.pl "{}" \;
|
||||
|
|
@ -7,7 +7,7 @@ use File::Basename;
|
|||
my $indentation = 2;
|
||||
|
||||
if ($#ARGV != 0) {
|
||||
print "\nUsage: simplecheck.pl source\n";
|
||||
print "\nUsage: stylecheck.pl source\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
|
@ -30,13 +30,13 @@ my $state = "start";
|
|||
sub style {
|
||||
my $desc = shift;
|
||||
|
||||
print("style: $desc at line $lineno in \"$filename\"\n");
|
||||
print("style: $desc at line $lineno in \"$source\"\n");
|
||||
}
|
||||
|
||||
sub error {
|
||||
my $desc = shift;
|
||||
|
||||
print("error: $desc at line $lineno in \"$filename\"\n");
|
||||
print("error: $desc at line $lineno in \"$source\"\n");
|
||||
}
|
||||
|
||||
my $emptycnt = 0;
|
|
@ -1,354 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
use strict;
|
||||
use warnings;
|
||||
use File::Basename;
|
||||
|
||||
# Desired indentation.
|
||||
my $indentation = 2;
|
||||
|
||||
if ($#ARGV != 0) {
|
||||
print "\nUsage: stylecheck.pl source\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
my $source = $ARGV[0];
|
||||
|
||||
open(my $in, "<", $source) or die "Can't open source: $!";
|
||||
|
||||
my $lineno = 0;
|
||||
my @c_source = <$in>;
|
||||
my $filename = $source;
|
||||
$filename =~ y/\\/\//;
|
||||
$filename = basename($filename);
|
||||
|
||||
my $i_level = 0;
|
||||
my $c_comment = "";
|
||||
my $state = "start";
|
||||
my $cr = "\r";
|
||||
my $lf = "\n";
|
||||
my $tab = "\t";
|
||||
my $f_lineno = 0;
|
||||
my $f_params = "";
|
||||
my $t_lineno = 0;
|
||||
my $t_type = "";
|
||||
my $e_lineno = 0;
|
||||
my $e_name = "";
|
||||
my $d_lineno = 0;
|
||||
my $d_name = "";
|
||||
my $d_name2 = "";
|
||||
my $d_name_app = "";
|
||||
my $scope = "";
|
||||
|
||||
sub style {
|
||||
my $desc = shift;
|
||||
|
||||
print("style: $desc at line $lineno in \"$filename\"\n");
|
||||
}
|
||||
|
||||
sub error {
|
||||
my $desc = shift;
|
||||
|
||||
print("error: $desc at line $lineno in \"$filename\"\n");
|
||||
}
|
||||
|
||||
# Indentation check.
|
||||
sub check_indentation {
|
||||
|
||||
shift =~ /^(\s*)/;
|
||||
if (length($1) != $i_level) {
|
||||
style "indentation violation";
|
||||
}
|
||||
}
|
||||
|
||||
my $emptycnt = 0;
|
||||
foreach my $line (@c_source) {
|
||||
|
||||
$lineno += 1;
|
||||
|
||||
#****************************************************************************
|
||||
# Check on EOL.
|
||||
if (not ($line =~ /$cr$lf$/)) {
|
||||
error "detected malformed EOL";
|
||||
}
|
||||
$line =~ s/$cr//;
|
||||
$line =~ s/$lf//;
|
||||
|
||||
#****************************************************************************
|
||||
# Check on trailing spaces.
|
||||
if ($line =~ /\s$/) {
|
||||
style "detected trailing spaces";
|
||||
}
|
||||
|
||||
#****************************************************************************
|
||||
# Check on TABs.
|
||||
if ($line =~ /$tab/) {
|
||||
style "detected TAB";
|
||||
$line =~ s/$tab/ /;
|
||||
}
|
||||
|
||||
#****************************************************************************
|
||||
# Check on empty lines.
|
||||
my $tmp = $line;
|
||||
$tmp =~ s/\s//;
|
||||
if (length($tmp) == 0) {
|
||||
$emptycnt = $emptycnt + 1;
|
||||
if ($emptycnt == 2) {
|
||||
style "detected multiple empty lines"
|
||||
}
|
||||
next;
|
||||
}
|
||||
else {
|
||||
$emptycnt = 0;
|
||||
}
|
||||
|
||||
#****************************************************************************
|
||||
# Stripping strings content for ease of parsing, all strings become _string_.
|
||||
$line =~ s/\\\"//;
|
||||
if ($line =~ s/(\"[^"]*\")/_string_/) {
|
||||
# print "string: $1 replaced by _string_\n";
|
||||
}
|
||||
|
||||
#******************************************************************************
|
||||
# State machine handling.
|
||||
if ($state eq "start") {
|
||||
# Searching for a global code element or a comment start.
|
||||
|
||||
# Indentation check.
|
||||
check_indentation $line;
|
||||
|
||||
#******************************************************************************
|
||||
# Functions matching, triggered by the "(".
|
||||
if ($line =~ /^(static|)\s*(struct|union|)\s*([a-zA-Z_][a-zA-Z0-9_]*\s*[*]*)\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\(/) {
|
||||
# $1=scope $2$3=return type $4=name
|
||||
$line =~ s/^(static|)\s*(struct|union|)\s*([a-zA-Z_][a-zA-Z0-9_]*\s*[*]*)\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\(//;
|
||||
# print "function: " . $1 . " " . $2 . " " . $3 . " " . $4 . "(";
|
||||
|
||||
# Size of the match up to parameters.
|
||||
my $size = $+[0] - $-[0];
|
||||
|
||||
# Function line number.
|
||||
$f_lineno = $lineno;
|
||||
|
||||
# Checking if all parameters are on the same line.
|
||||
if ($line =~ /.*\)\s*{\s*$/) {
|
||||
$line =~ s/\)\s*{\s*$//;
|
||||
# print $line . "\n";
|
||||
$f_params = $line;
|
||||
$i_level = $indentation;
|
||||
$state = "infunc";
|
||||
}
|
||||
else {
|
||||
# print $line;
|
||||
$f_params = $line;
|
||||
$i_level = $size;
|
||||
$state = "inparams";
|
||||
}
|
||||
}
|
||||
#******************************************************************************
|
||||
# Structures matching.
|
||||
elsif ($line =~ /^\s*struct\s+([a-zA-Z_][a-zA-Z0-9_]*)/) {
|
||||
}
|
||||
#******************************************************************************
|
||||
# Single line "typedef" matching.
|
||||
elsif ($line =~ /^\s*typedef\s+([\sa-zA-Z0-9_]*\*+)\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*;\s*$/ or
|
||||
$line =~ /^\s*typedef\s+([\sa-zA-Z0-9_]*)\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*;\s*$/) {
|
||||
}
|
||||
#******************************************************************************
|
||||
# Single line "typedef function" matching.
|
||||
elsif ($line =~ /^\s*typedef\s+.*\(\s*\*\s*([a-zA-Z0-9_]*)\s*\)\(/) {
|
||||
}
|
||||
#******************************************************************************
|
||||
# Multi line "typedef struct" matching.
|
||||
elsif ($line =~ /^\s*typedef\s*struct\s*([a-zA-Z_][a-zA-Z0-9_]*|\s?)?/) {
|
||||
$t_lineno = $lineno;
|
||||
$t_type = "struct " . $1;
|
||||
$state = "intypedef";
|
||||
}
|
||||
#******************************************************************************
|
||||
# Multi line "typedef enum" matching.
|
||||
elsif ($line =~ /^\s*typedef\s*enum\s*([a-zA-Z_][a-zA-Z0-9_]*|\s?)?/) {
|
||||
$t_lineno = $lineno;
|
||||
$t_type = "enum " . $1;
|
||||
if ($line =~ /([a-zA-Z_][a-zA-Z0-9_]*)\s*;\s*$/) {
|
||||
# Special case of a single-line typedef enum.
|
||||
}
|
||||
else {
|
||||
$state = "intypedef";
|
||||
}
|
||||
}
|
||||
#******************************************************************************
|
||||
# Multi line "enum" matching.
|
||||
elsif ($line =~ /^\s*enum\s*([a-zA-Z_][a-zA-Z0-9_]*)/) {
|
||||
$e_name = $1;
|
||||
$e_lineno = $lineno;
|
||||
if ($line =~ /;\s*$/) {
|
||||
# Special case of a single-line enum.
|
||||
}
|
||||
else {
|
||||
$state = "inenum";
|
||||
}
|
||||
}
|
||||
#******************************************************************************
|
||||
# Struct variable matching.
|
||||
elsif ($line =~ /^\s*(static|)\s+([\sa-zA-Z0-9_]*)\s+([a-zA-Z_][a-zA-Z0-9_]*\[.*\]|[a-zA-Z_][a-zA-Z0-9_]*)\s*(;\s*$|=)/ or
|
||||
$line =~ /^\s*(static|)\s+([\sa-zA-Z0-9_]*\*+)\s*([a-zA-Z_][a-zA-Z0-9_]*\[.*\]|[a-zA-Z_][a-zA-Z0-9_]*)\s*(;\s*$|=)/) {
|
||||
}
|
||||
#******************************************************************************
|
||||
# Variable matching.
|
||||
elsif ($line =~ /^\s*(static|).*\s+([a-zA-Z_][a-zA-Z0-9_]*\s*\*+|[a-zA-Z_][a-zA-Z0-9_]*)\s*([a-zA-Z_][a-zA-Z0-9_]*\[.*\]|[a-zA-Z_][a-zA-Z0-9_]*)\s*(;\s*$|=)/) {
|
||||
# variable declaration.
|
||||
}
|
||||
#******************************************************************************
|
||||
# #nclude matching.
|
||||
elsif ($line =~ /^\s*#include\s+"([^"]+)"/) {
|
||||
}
|
||||
#******************************************************************************
|
||||
# #if matching.
|
||||
elsif ($line =~ /^\s*#if\s+(.+)/) {
|
||||
}
|
||||
#******************************************************************************
|
||||
# #ifdef matching.
|
||||
elsif ($line =~ /^\s*#ifdef\s+([\w_]+)/) {
|
||||
}
|
||||
#******************************************************************************
|
||||
# #define matching.
|
||||
elsif ($line =~ /^\s*#define\s+([\w_]+)\s*(.*)/) {
|
||||
$d_lineno = $lineno;
|
||||
$d_name = $1;
|
||||
$d_name2 = $2;
|
||||
# enum typedef declaration.
|
||||
if ($line =~ /[^\\]$/) {
|
||||
# Special case of a single-line typedef enum.
|
||||
}
|
||||
else {
|
||||
$state = "indefine";
|
||||
}
|
||||
}
|
||||
#******************************************************************************
|
||||
# Comment start matching.
|
||||
elsif ("$line" =~ /^\s*\/\*/) {
|
||||
if ("$line" =~ /\*\//) {
|
||||
# Special case of single line comments.
|
||||
$line =~ /^\s*(\/\*.*\*\/)/;
|
||||
}
|
||||
else {
|
||||
# Start of multi-line comment.
|
||||
$line =~ /(\/\*.*)/;
|
||||
$c_comment = $1 . " ";
|
||||
$state = "incomment";
|
||||
}
|
||||
}
|
||||
}
|
||||
#******************************************************************************
|
||||
# Scanning for function parameters end and function body begin.
|
||||
elsif ($state eq "inparams") {
|
||||
|
||||
# Indentation check.
|
||||
check_indentation $line;
|
||||
|
||||
if ($line =~ /.*\)\s*{\s*$/) {
|
||||
# print $line . "\n";
|
||||
$line =~ s/\)\s*{\s*$//;
|
||||
$f_params = $f_params . $line;
|
||||
$i_level = $indentation;
|
||||
$state = "infunc";
|
||||
print "$f_params\n";
|
||||
}
|
||||
else {
|
||||
$f_params = $f_params . $line;
|
||||
# print $line;
|
||||
}
|
||||
}
|
||||
#******************************************************************************
|
||||
# Scanning for function end.
|
||||
elsif ($state eq "infunc") {
|
||||
|
||||
# Checking for function end, the final "}".
|
||||
if ($line =~ /^\}/) {
|
||||
$i_level = 0;
|
||||
$state = "start";
|
||||
next;
|
||||
}
|
||||
|
||||
# Indentation check.
|
||||
check_indentation $line;
|
||||
|
||||
if ($line =~ /(\/\*.*\*\/)/) {
|
||||
# Single line comments inside functions.
|
||||
}
|
||||
elsif ("$line" =~ /(\/\*.*)/) {
|
||||
# Start of multi-line comment inside a function.
|
||||
$c_comment = $1 . " ";
|
||||
$state = "infunccomment";
|
||||
}
|
||||
}
|
||||
#******************************************************************************
|
||||
# Scanning for comment end within a function body.
|
||||
elsif ($state eq "infunccomment") {
|
||||
if ("$line" =~ /\*\/\s*$/) {
|
||||
# End of mult-line comment.
|
||||
$line =~ /(.*\*\/)/;
|
||||
$c_comment .= $1;
|
||||
|
||||
$state = "infunc";
|
||||
}
|
||||
else {
|
||||
# Add the whole line.
|
||||
$c_comment .= $line . " ";
|
||||
}
|
||||
}
|
||||
#******************************************************************************
|
||||
# Scanning for comment end.
|
||||
elsif ($state eq "incomment") {
|
||||
if ("$line" =~ /\*\/\s*$/) {
|
||||
# End of mult-line comment.
|
||||
$line =~ /(.*\*\/)/;
|
||||
$c_comment .= $1;
|
||||
|
||||
$state = "start";
|
||||
}
|
||||
else {
|
||||
# Add the whole line.
|
||||
$c_comment .= $line . " ";
|
||||
}
|
||||
}
|
||||
#******************************************************************************
|
||||
# Scanning for typedef end.
|
||||
elsif ($state eq "intypedef") {
|
||||
if ($line =~ /^\s*}\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*;\s*$/) {
|
||||
# typedef end because the final '} <name>;'.
|
||||
|
||||
$state = "start";
|
||||
}
|
||||
}
|
||||
#******************************************************************************
|
||||
# Scanning for enum end.
|
||||
elsif ($state eq "inenum") {
|
||||
if ($line =~ /^\s*}\s*;\s*$/) {
|
||||
# enum end because the final '};'.
|
||||
|
||||
$state = "start";
|
||||
}
|
||||
}
|
||||
#******************************************************************************
|
||||
# Scanning for define end.
|
||||
elsif ($state eq "indefine") {
|
||||
if ($line =~ /[^\\]$/) {
|
||||
# define end because the final 'not \'.
|
||||
# remove blank from starting of the line
|
||||
$line =~ s/^\s+|\s+$//g;
|
||||
# Add the whole line.
|
||||
$d_name2 .= $line;
|
||||
|
||||
$state = "start";
|
||||
}
|
||||
else {
|
||||
# Add the whole line.
|
||||
# $line =~ s/^\s+|\s+$//g;
|
||||
$line =~ s/^\s*(.*?)\s*$/$1/;
|
||||
$d_name2 .= $line;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close $in or die "$in: $!";
|
21
tools/test.c
21
tools/test.c
|
@ -1,21 +0,0 @@
|
|||
static struct pippo **pluto (void) {
|
||||
|
||||
}
|
||||
|
||||
static struct pp qq (void) {
|
||||
|
||||
}
|
||||
|
||||
static cc ss (void) {
|
||||
|
||||
}
|
||||
|
||||
static aa bb (int a,
|
||||
char *p) {
|
||||
|
||||
}
|
||||
|
||||
dd *ee (void) {
|
||||
|
||||
bb(0, "pip\"po", "pluto");
|
||||
}
|
Loading…
Reference in New Issue