提交 ddcc35f5 创建 作者: 赵鹏翀's avatar 赵鹏翀

Merge branch 'fix-tiny' into 'master'

提交作业 See merge request !1
流水线 #153765 已通过 于阶段
用时 39 秒
...@@ -5,10 +5,10 @@ ...@@ -5,10 +5,10 @@
"label": "生成项目(make)", "label": "生成项目(make)",
"type": "shell", "type": "shell",
"windows": { "windows": {
"command": "cat \"${execPath}.tips\\env_tip.txt\" ; echo VSCode安装路径-${execPath} ; echo 正在生成项目 ; make" "command": "cat \"${execPath}.tips\\env_tip.txt\" ; echo VSCode安装路径-${execPath} ; echo 正在使用makefile文件生成项目 ; make"
}, },
"linux": { "linux": {
"command": "echo 正在生成项目 && make && echo 生成项目成功" "command": "echo 正在使用makefile文件生成项目 && make && echo 生成项目成功"
}, },
"args": [], "args": [],
"group": "build", "group": "build",
...@@ -57,10 +57,10 @@ ...@@ -57,10 +57,10 @@
"label": "清理项目(make clean)", "label": "清理项目(make clean)",
"type": "shell", "type": "shell",
"windows": { "windows": {
"command": "cat \"${execPath}.tips\\env_tip.txt\" ; echo VSCode安装路径-${execPath} ; echo 正在清理项目 ; make clean" "command": "cat \"${execPath}.tips\\env_tip.txt\" ; echo VSCode安装路径-${execPath} ; echo 正在使用makefile文件清理项目 ; make clean"
}, },
"linux": { "linux": {
"command": "echo 正在清理项目 && make clean && echo 清理项目成功" "command": "echo 正在使用makefile文件清理项目 && make clean && echo 清理项目成功"
}, },
"args": [], "args": [],
"group": "build", "group": "build",
......
...@@ -88,7 +88,7 @@ def compare_file(file1, file2, seqNum, caseCount, bIncludeCi): ...@@ -88,7 +88,7 @@ def compare_file(file1, file2, seqNum, caseCount, bIncludeCi):
print('文件路径不能为空:第一个文件的路径:{0}, 第二个文件的路径:{1} .'.format(file1, file2)) print('文件路径不能为空:第一个文件的路径:{0}, 第二个文件的路径:{1} .'.format(file1, file2))
sys.exit() sys.exit()
else: else:
print("正在比较文件 {0} 和 {1}".format(file1, file2), end=': ') print("正在比较标准答案输出文件 {0} 和用户编写的应用程序输出文件 {1}".format(file1, file2), end=': ')
if os.path.isfile(file1) and os.path.isfile(file2) and advanced_file_compare(file1, file2): if os.path.isfile(file1) and os.path.isfile(file2) and advanced_file_compare(file1, file2):
print("文件相同") print("文件相同")
...@@ -107,7 +107,8 @@ def compare_file(file1, file2, seqNum, caseCount, bIncludeCi): ...@@ -107,7 +107,8 @@ def compare_file(file1, file2, seqNum, caseCount, bIncludeCi):
outputPromptInfo(bIncludeCi, promptInfo, 1) outputPromptInfo(bIncludeCi, promptInfo, 1)
if seqNum == caseCount: if seqNum == caseCount:
print("恭喜你,通过了所有的测试!") promptInfo = "恭喜你通过了所有测试!"
outputPromptInfo(bIncludeCi, promptInfo, 1)
returnVal = 1 returnVal = 1
return returnVal return returnVal
...@@ -163,22 +164,17 @@ def outputPromptInfo(bIncludeCi, promptInfo, color): ...@@ -163,22 +164,17 @@ def outputPromptInfo(bIncludeCi, promptInfo, color):
if __name__ == "__main__": if __name__ == "__main__":
if bIncludeCi == False:
print("开发环境中的 Python 解释器版本号:" + platform.python_version())
print()
compResultFile = "result_comparation.html" compResultFile = "result_comparation.html"
if os.path.isfile(compResultFile): if os.path.isfile(compResultFile):
os.remove(compResultFile) os.remove(compResultFile)
promptInfo = "正在使用make生成项目" promptInfo = "正在使用 makefile 文件生成项目"
outputPromptInfo(bIncludeCi, promptInfo, 1) outputPromptInfo(bIncludeCi, promptInfo, 1)
execResult = os.system("make") execResult = os.system("make")
if execResult != 0: if execResult != 0:
errorInfo = "应用程序异常,返回值:{0}。".format(execResult) errorInfo = "生成项目失败"
outputPromptInfo(bIncludeCi, errorInfo, 2) outputPromptInfo(bIncludeCi, errorInfo, 2)
exit(1) exit(1)
else: else:
...@@ -186,12 +182,12 @@ if __name__ == "__main__": ...@@ -186,12 +182,12 @@ if __name__ == "__main__":
if not os.path.isfile("output1.txt"): if not os.path.isfile("output1.txt"):
score = 100 score = 100
if bIncludeCi: if bIncludeCi:
promptInfo = "项目生成成功" promptInfo = "生成项目成功"
outputPromptInfo(bIncludeCi, promptInfo, 1) outputPromptInfo(bIncludeCi, promptInfo, 1)
promptInfo = "exec-score {0}".format(score) promptInfo = "exec-score {0}".format(score)
print(promptInfo) print(promptInfo)
else: else:
promptInfo = "项目生成成功, 分数 {0}".format(score) promptInfo = "生成项目成功, 分数 {0}".format(score)
outputPromptInfo(bIncludeCi, promptInfo, 1) outputPromptInfo(bIncludeCi, promptInfo, 1)
...@@ -245,9 +241,6 @@ if __name__ == "__main__": ...@@ -245,9 +241,6 @@ if __name__ == "__main__":
print("使用的标准输入文件是 intput{0}.txt。\n标准答案输出文件 output{1}.txt(左边)与用户编写的应用程序输出文件 user_output{2}.txt(右边)的比较结果:".format(seqNum, seqNum, seqNum)) print("使用的标准输入文件是 intput{0}.txt。\n标准答案输出文件 output{1}.txt(左边)与用户编写的应用程序输出文件 user_output{2}.txt(右边)的比较结果:".format(seqNum, seqNum, seqNum))
runCommand = "diff {0} {1} -b -B -y -i -W 100".format(outputFile, useroutputFile) runCommand = "diff {0} {1} -b -B -y -i -W 100".format(outputFile, useroutputFile)
execResult = os.system(runCommand) execResult = os.system(runCommand)
#if execResult != 0:
# errorInfo = "输出结果比较异常,返回值:{0}。".format(execResult)
# outputPromptInfo(bIncludeCi, errorInfo, 2)
else: else:
promptInfo = "查看文件比较结果可帮助你查找验证失败的原因。方法是:\n选择 View 菜单中的 Explorer 打开文件列表,右键点击 result_comparation.html 文件,在弹出的菜单中选择 Open Preview" promptInfo = "查看文件比较结果可帮助你查找验证失败的原因。方法是:\n选择 View 菜单中的 Explorer 打开文件列表,右键点击 result_comparation.html 文件,在弹出的菜单中选择 Open Preview"
outputPromptInfo(bIncludeCi, promptInfo, 2) outputPromptInfo(bIncludeCi, promptInfo, 2)
......
void fun()
{
int a, b;
b = a;
  • Developer

    🔽 Variable 'b' is assigned a value that is never used. 📘

Please register or sign in to reply
}
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
void fun();
int main() int main()
{ {
int x, y; int x, y;
int *p = malloc(8); int *p = malloc(8);
fun();
scanf("%d", &x); scanf("%d", &x);
......
...@@ -16,9 +16,11 @@ CC = gcc ...@@ -16,9 +16,11 @@ CC = gcc
CFLAGS = -g -w -fmax-errors=10 -std=c99 -fsigned-char -I${DIR_INC} CFLAGS = -g -w -fmax-errors=10 -std=c99 -fsigned-char -I${DIR_INC}
${BIN_TARGET}:${OBJ} ${BIN_TARGET}:${OBJ}
@echo --- build executable file: $@
$(CC) $(OBJ) -o $@ $(CC) $(OBJ) -o $@
${DIR_OBJ}/%.o:${DIR_SRC}/%.c ${DIR_OBJ}/%.o:${DIR_SRC}/%.c
@echo --- build object file: $@
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@
RM = @echo 无法识别的平台。无法删除文件 RM = @echo 无法识别的平台。无法删除文件
......
  • Developer

    代码质量分析发现了 7 个问题。

    • 0 blocker
    • 🚫 0 critical
    • 2 major
    • 🔽 3 minor
    • 2 info

    1 个问题使用代码行评论的方式进行报告,请在此次变更的代码行中审阅这些问题。

    6 个额外的问题

    注意: 存在下列问题的代码行在本次提交中没有发生变更,无法使用代码行评论的方式进行报告。所以将下列问题汇总显示在这里(点击问题链接可以转到对应的源代码行):

    1. [8 bytes in 1 blocks are definitely lost in loss record 1 of 1

    0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) 0x400666: main (main.c:9)](https://www.codecode.net/engintime-cs/teacher-group/zpc/test-vscode-c-win/blob/ddcc35f5ba82df5c1528604ca464fd8f312e9bcf/main.c#L9) 📘

    1. Memory leak: p 📘
    2. 🔽 Cppcheck cannot find all the include files. Cppcheck can check the code without the include files found. But the results will probably be more accurate if all the include files are found. Please check your project's include directories and add all of them as include directories for Cppcheck. To see what files Cppcheck cannot find use --check-config. (ProjectKey-172761) 📘
    3. 🔽 Variable 'p' is allocated memory that is never used. 📘
    4. keyword 'if' not followed by a single space 📘
    5. keyword 'if' not followed by a single space 📘
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论