Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions gitgalaxy/standards/language_standards.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
| Language | Func Recall | Func Precision | Class Recall | Class Precision |
| -------- | ----------- | -------------- | ------------ | --------------- |
| Apex | 100.0% | 95.0% | 100.0% | 100.0% |
| C | 93.3% | 99.5% | 100.0% | 100.0% |
| C | 99.7% | 99.5% | 100.0% | 100.0% |
| Cpp | 93.4% | 95.7% | 98.6% | 92.6% |
| Csharp | 99.2% | 99.8% | 100.0% | 100.0% |
| Css | 100.0% | 100.0% | N/A | N/A |
Expand Down Expand Up @@ -3408,12 +3408,15 @@ class PrismConfigSchema(TypedDict):
r"(?:(?:struct|union|enum)\s+)?"
# 4. Return type (Strictly linear)
r"(?:[a-zA-Z_]\w+\s+){0,3}[a-zA-Z_]\w*(?:\s*[*&]+\s*|\s+)"
# [ MACRO SHIELD ]: Support macros between return type and function name (e.g. PyAPI_FUNC(int) or _Py_HOT_FUNCTION)
r"(?:[a-zA-Z_]\w+(?:\s*\([^)]*\))?\s+){0,5}"
# 5. The "Not a Function" Shield
r"(?!(?:if|for|while|switch|return|sizeof)\b)"
# 6. The Identifier Capture (Satellite Name - Group 1)
r"([a-zA-Z_]\w*)"
# 7. The Parameter Block
r"\s*\([^)]*\)"
# [NESTED PARENTHESIS FIX]: Uses 1-Level Nesting Trick to swallow function pointers and macros without ReDoS.
r"\s*\((?:[^)(]|\([^)]*\))*\)"
# 8. The K&R C Parameter Gap (Legacy support for DOOM/MS-DOS)
# [IRON WALL FIX]: Forces instant failure if it encounters BEGIN or control flow.
r"(?:\s+(?!(?:BEGIN|if|for|while|switch|return)\b)[a-zA-Z_][^;{]{0,150};){0,15}"
Expand Down
6 changes: 6 additions & 0 deletions tests/extraction/languages/test_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@
), # K&R old-style function definition
# Testing-framework-shaped functions that ARE real functions
("void test_TargetFunc(void) {", "test_TargetFunc"), # Unity-style test function
# Macros after return type and complex nested parenthesis args
("PyObject* _Py_HOT_FUNCTION DONT_SLP_VECTORIZE \n TargetFunc(PyThreadState *tstate) {", "TargetFunc"),
("int TargetFunc(PyObject* Py_UNUSED(consts)) {", "TargetFunc"),
("Py_ssize_t TargetFunc(int (*check_lookup)(PyDictObject *, Py_ssize_t)) {", "TargetFunc"),
# K&R style with macro return type
("PRIVATE void TargetFunc(out,plp,tag)\nFILE *out;\nstruct plink *plp;\nchar *tag;\n{", "TargetFunc"),
],
"invalid": [
"typedef struct TargetFunc {", # struct decl lookalike
Expand Down
Loading
Loading