|
|
| version 1.3, 2025/03/09 15:20:18 | version 1.7, 2025/04/10 01:24:38 |
|---|---|
| Line 1 | Line 1 |
| /* | /* |
| * * | * $Id$ |
| * * * | |
| * * * | |
| * *************** | |
| * * * * * | |
| * * MUMPS * | |
| * * * * * | |
| * *************** | |
| * * * | |
| * * * | |
| * * | |
| * | |
| * mref.c | |
| * supporting functions for handling freem_ref_t structures | * supporting functions for handling freem_ref_t structures |
| * | * |
| * | * |
| * Author: Serena Willis <snw@coherent-logic.com> | * Author: Serena Willis <snw@coherent-logic.com> |
| * Copyright (C) 1998 MUG Deutschland | * Copyright (C) 1998 MUG Deutschland |
| * Copyright (C) 2020 Coherent Logic Development LLC | * Copyright (C) 2020, 2025 Coherent Logic Development LLC |
| * | * |
| * | * |
| * This file is part of FreeM. | * This file is part of FreeM. |
| Line 35 | Line 23 |
| * You should have received a copy of the GNU Affero Public License | * You should have received a copy of the GNU Affero Public License |
| * along with FreeM. If not, see <https://www.gnu.org/licenses/>. | * along with FreeM. If not, see <https://www.gnu.org/licenses/>. |
| * | * |
| * $Log$ | |
| * Revision 1.7 2025/04/10 01:24:38 snw | |
| * Remove C++ style comments | |
| * | |
| * Revision 1.6 2025/04/09 15:16:50 snw | |
| * Fix buffer overruns in mref_to_external and ssvn.c | |
| * | |
| * Revision 1.5 2025/03/22 18:43:54 snw | |
| * Make STRLEN 255 chars and add BIGSTR macro for larger buffers | |
| * | |
| * Revision 1.4 2025/03/09 19:50:47 snw | |
| * Second phase of REUSE compliance and header reformat | |
| * | |
| * | |
| * SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC | |
| * SPDX-License-Identifier: AGPL-3.0-or-later | |
| **/ | **/ |
| #include <stdio.h> | #include <stdio.h> |
| Line 167 freem_ref_t *internal_to_mref (freem_ref | Line 171 freem_ref_t *internal_to_mref (freem_ref |
| ref->reftype = MREF_RT_LOCAL; | ref->reftype = MREF_RT_LOCAL; |
| } | } |
| strncpy (ref->name, nam, 256); | strncpy (ref->name, nam, STRLEN); |
| /* if no subscripts, return the ref */ | /* if no subscripts, return the ref */ |
| if (*(ptr - 1) == EOL) { | if (*(ptr - 1) == EOL) { |
| Line 270 void mref_to_external (freem_ref_t *ref, | Line 274 void mref_to_external (freem_ref_t *ref, |
| } | } |
| } | } |
| stcnv_m2c (buf); | stncnv_m2c (buf, STRLEN); |
| strcat (buf, ")"); | strcat (buf, ")"); |
| Line 286 short mref_is_descendant(freem_ref_t *a, | Line 290 short mref_is_descendant(freem_ref_t *a, |
| { | { |
| register int i; | register int i; |
| //printf ("checking if %s is a descendant of %s\r\n", b->name, a->name); | |
| //printf ("a: %d b: %d\r\n", a->subscript_count, b->subscript_count); | |
| if (a->subscript_count > b->subscript_count) return FALSE; | if (a->subscript_count > b->subscript_count) return FALSE; |
| if ((strcmp (a->name, b->name) == 0) && (a->subscript_count == 0)) return TRUE; | if ((strcmp (a->name, b->name) == 0) && (a->subscript_count == 0)) return TRUE; |
| for (i = 0; i < a->subscript_count; i++) { | for (i = 0; i < a->subscript_count; i++) { |
| //printf("\ta[%d] = '%s'\r\n\tb[%d] = '%s'\r\n", i, a->subscripts[i], i, b->subscripts[i]); | |
| if (strcmp (b->subscripts[i], a->subscripts[i]) != 0 ) { | if (strcmp (b->subscripts[i], a->subscripts[i]) != 0 ) { |
| //printf ("not descendant [%d]\r\n", strcmp (b->subscripts[i], a->subscripts[i])); | |
| return FALSE; | return FALSE; |
| } | } |
| } | } |
| //printf ("is descendant\r\n"); | |
| return TRUE; | return TRUE; |
| } | } |