vishapoberon / compiler

vishap oberon compiler
http://oberon.vishap.am
GNU General Public License v3.0
186 stars 25 forks source link

Introducing SYSTEM.MAXPATHLEN and SYSTEM.MAXFILENAMELEN #65

Closed runkharr closed 6 years ago

runkharr commented 6 years ago

Hi!

This is my first pull request ... so, sorry if my explanations are somewhat long.

I modified 'src/tools/make/configure.c' in a way that it inserts 'PATH_MAX' and 'NAME_MAX' (as exported constants 'MaxPathLen' and 'MaxFnLen' into 'Configuration.Mod', thus allowing the system's limits for pathnames to be used. In the next step, i modified 'src/compiler/OPT.Mod' - importing 'Configuration', implementing 'EnterIntConst()' (using 'EnterBoolConst()' as a prototype) and adding the two new constants MAXPATHLEN ('Configuration.MaxPathLen') and MAXFILENAMELEN ('Configuration.MaxFnLen') to the pseudo-module SYSTEM.

This allows for using the limits for path- and filenames of the system the compiler was generated on. Somewhat tricky, i know, but this should solve some of the problems with too short pathname-buffers.

If this modification is accepted, i will make modifications on 'src/runtime/Files.Mod', removing (most of) the buffer overflow problems i found in this file. (Fact is, already made these modifications, but i couldn't test the module yet ...)

norayr commented 6 years ago

Thank you! Merged.

When you change the compiler, you also need to regenerate bootstrap sources with 'make bootstrap'. So next pull request has to contain also modified C bootstrap sources.

I am waiting for your Files modifications.

Right now I am not sure introducing new import dependency to OPT.Mod is necessary, but for now I would like to encourage you to continue your contributions.

Thanks again.

norayr commented 6 years ago

also it's interesting if limits.h exists on all supported architectures, let's say on android target, and indeed contains constant with the same name.