CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
85 lines
2.2 KiB
C
85 lines
2.2 KiB
C
/*
|
|
** This program checks for formatting problems in source code:
|
|
**
|
|
** * Any use of tab characters
|
|
** * White space at the end of a line
|
|
** * Blank lines at the end of a file
|
|
**
|
|
** Any violations are reported.
|
|
*/
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#define CR_OK 0x001
|
|
#define WSEOL_OK 0x002
|
|
|
|
static void checkSpacing(const char *zFile, unsigned flags){
|
|
FILE *in = fopen(zFile, "rb");
|
|
int i;
|
|
int seenSpace;
|
|
int seenTab;
|
|
int ln = 0;
|
|
int lastNonspace = 0;
|
|
char zLine[2000];
|
|
if( in==0 ){
|
|
printf("cannot open %s\n", zFile);
|
|
return;
|
|
}
|
|
while( fgets(zLine, sizeof(zLine), in) ){
|
|
seenSpace = 0;
|
|
seenTab = 0;
|
|
ln++;
|
|
for(i=0; zLine[i]; i++){
|
|
if( zLine[i]=='\t' && seenTab==0 ){
|
|
printf("%s:%d: tab (\\t) character\n", zFile, ln);
|
|
seenTab = 1;
|
|
}else if( zLine[i]=='\r' ){
|
|
if( (flags & CR_OK)==0 ){
|
|
printf("%s:%d: carriage-return (\\r) character\n", zFile, ln);
|
|
}
|
|
}else if( zLine[i]==' ' ){
|
|
seenSpace = 1;
|
|
}else if( zLine[i]!='\n' ){
|
|
lastNonspace = ln;
|
|
seenSpace = 0;
|
|
}
|
|
}
|
|
if( seenSpace && (flags & WSEOL_OK)==0 ){
|
|
printf("%s:%d: whitespace at end-of-line\n", zFile, ln);
|
|
}
|
|
}
|
|
fclose(in);
|
|
if( lastNonspace<ln ){
|
|
printf("%s:%d: blank lines at end of file (%d)\n",
|
|
zFile, ln, ln - lastNonspace);
|
|
}
|
|
}
|
|
|
|
int main(int argc, char **argv){
|
|
int i;
|
|
unsigned flags = WSEOL_OK;
|
|
for(i=1; i<argc; i++){
|
|
const char *z = argv[i];
|
|
if( z[0]=='-' ){
|
|
while( z[0]=='-' ) z++;
|
|
if( strcmp(z,"crok")==0 ){
|
|
flags |= CR_OK;
|
|
}else if( strcmp(z, "wseol")==0 ){
|
|
flags &= ~WSEOL_OK;
|
|
}else if( strcmp(z, "help")==0 ){
|
|
printf("Usage: %s [options] FILE ...\n", argv[0]);
|
|
printf(" --crok Do not report on carriage-returns\n");
|
|
printf(" --wseol Complain about whitespace at end-of-line\n");
|
|
printf(" --help This message\n");
|
|
}else{
|
|
printf("unknown command-line option: [%s]\n", argv[i]);
|
|
printf("use --help for additional information\n");
|
|
}
|
|
}else{
|
|
checkSpacing(argv[i], flags);
|
|
}
|
|
}
|
|
return 0;
|
|
}
|