Skip to content

Commit

Permalink
Fix warning
Browse files Browse the repository at this point in the history
  • Loading branch information
chenzhch committed Nov 25, 2024
1 parent 72f10e8 commit 0c084aa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 25 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ macOS 13|lldb|NO

### History

- v1.8.2 2024-11-25

Fix Issue #27

- v1.8.1 2024-11-11

Fix memory detection errors in special scenarios
Expand All @@ -105,7 +109,7 @@ macOS 13|lldb|NO

- v1.7 2024-09-18

Fix Issue # 18
Fix Issue #18

Safe mode SHELL human-machine interaction support does not modify the source script program

Expand Down
30 changes: 7 additions & 23 deletions shellc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Function: Convert script into C code
* Author: ChenZhongChao
* Birthdate: 2023-12-25
* Version: 1.8.1
* Version: 1.8.2
* Github: https://github.com/chenzhch/shellc.git
*/

Expand Down Expand Up @@ -272,22 +272,6 @@ static const char *fix_code[][2] = {
{0, 0}
};

static const char *arg_code[][2] = {
{0, 0}, /*bash*/
{"sprintf(name, \"set -a argv '%s'; \", argv[i]);", 0}, /*fish*/
{0, 0}, /*zsh*/
{"sprintf(name, \"push @ARGV, '%s'; \", argv[i]);", 0}, /*perl*/
{"sprintf(name, \"sys.argv.append('''%s'''); \", argv[i]);", 0}, /*python*/
{"sprintf(name, \"process.argv.push(`%s`); \", argv[i]);", 0}, /*javascript*/
{"sprintf(name, \"table.insert(arg, '%s'); \", argv[i]);", 0}, /*lua*/
{"sprintf(name, \"ARGV.push('%s'); \", argv[i]);", 0}, /*ruby*/
{"sprintf(name, \"set argv = ($argv %s); \", argv[i]);", 0}, /*csh*/
{"sprintf(name, \"set argv [concat $argv %s]; \", argv[i]);", 0}, /*tclsh*/
{"sprintf(name, \"array_push($argv, '%s'); \", argv[i]);", 0}, /*php*/
{"sprintf(name, \"* = ($* %s); \", argv[i]);", 0}, /*rc*/
{0, 0}
};

static const char *sysname[] = {
"NetBSD",
"Darwin",
Expand Down Expand Up @@ -1028,7 +1012,7 @@ int main(int argc, char **argv)
memset(digest, 0, sizeof(digest));
sprintf(digest, "%064d", 0);

if(argc > strlen(option)) {
if(argc > (int) strlen(option)) {
fprintf(stderr, "Usage: %s %s\n", argv[0], usage);
return(1);
}
Expand All @@ -1042,7 +1026,7 @@ int main(int argc, char **argv)
for (i = 1; i < argc; i++) {
if (argv[i][0] == '-') {
if (strlen(argv[i]) > 1) {
for (k = 0; k < strlen(option); k++) {
for (k = 0; k < (int) strlen(option); k++) {
if (option[k] == argv[i][1]) break;
}
args[j++] = strdup(argv[i]);
Expand Down Expand Up @@ -1149,7 +1133,7 @@ int main(int argc, char **argv)
fprintf(stderr, "Error: invalid date format\n");
goto finish;
}
for (i = 0; i < strlen(date_str); i++) {
for (i = 0; i < (int) strlen(date_str); i++) {
if (date_str[i] < '0' || date_str[i] > '9') {
fprintf(stderr, "Error: invalid date format\n");
goto finish;
Expand Down Expand Up @@ -1527,7 +1511,7 @@ int main(int argc, char **argv)

while (fix_code[fix_pos][i]) {
length += strlen(fix_code[fix_pos][i]);
for (j = 0; j < strlen(fix_code[fix_pos][i]); j++) {
for (j = 0; j < (int) strlen(fix_code[fix_pos][i]); j++) {
if (fix_code[fix_pos][i][j] == '?') {
k++;
}
Expand All @@ -1539,7 +1523,7 @@ int main(int argc, char **argv)
while (fix_code[fix_pos][i]) {
fprintf(out, " sprintf(name, \"");
k = 0;
for (j = 0; j < strlen(fix_code[fix_pos][i]); j++) {
for (j = 0; j < (int) strlen(fix_code[fix_pos][i]); j++) {
if (fix_code[fix_pos][i][j] == '?') {
fputc('%', out);
fputc('s', out);
Expand Down Expand Up @@ -1579,7 +1563,7 @@ int main(int argc, char **argv)
while (fgets(str, sizeof(str), fix_file)) {
fprintf(out, " sprintf(name, \"");
k = 0;
for (j = 0; j < strlen(str) - 1; j++) {
for (j = 0; j < (int) strlen(str) - 1; j++) {
if (str[j] == '?') {
fputc('%', out);
fputc('s', out);
Expand Down
6 changes: 5 additions & 1 deletion 说明.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ macOS 13|lldb|不支持

### 修改记录

- v1.8 2024-11-11
- v1.8.2 2024-11-25

修复问题#27

- v1.8.1 2024-11-11

修复特殊场景内存检测错误

Expand Down

0 comments on commit 0c084aa

Please sign in to comment.