From e46757f1f78fae7085706d4741bb0a1109c08ec0 Mon Sep 17 00:00:00 2001 From: flywind Date: Sun, 7 Mar 2021 19:08:41 +0800 Subject: [PATCH] use lowercase --define switches (#17283) --- koch.nim | 2 +- lib/posix/posix.nim | 2 +- lib/pure/fenv.nim | 2 +- lib/pure/includes/oserr.nim | 2 +- lib/pure/math.nim | 2 +- lib/pure/nativesockets.nim | 4 +-- lib/pure/net.nim | 2 +- lib/pure/os.nim | 34 +++++++++---------- lib/pure/osproc.nim | 2 +- lib/system/arithm.nim | 2 +- lib/system/io.nim | 6 ++-- lib/system/syslocks.nim | 2 +- lib/wrappers/mysql.nim | 4 +-- lib/wrappers/openssl.nim | 2 +- testament/categories.nim | 2 +- .../keineschweine/dependencies/enet/enet.nim | 4 +-- tests/manyloc/keineschweine/lib/glut.nim | 2 +- tests/niminaction/Chapter8/sdl/sdl.nim | 6 ++-- tests/stdlib/tos.nim | 4 +-- tests/stdlib/tosprocterminate.nim | 2 +- tests/template/tmodulealias.nim | 2 +- 21 files changed, 45 insertions(+), 45 deletions(-) diff --git a/koch.nim b/koch.nim index 477b4424b3e19..973f21b9da520 100644 --- a/koch.nim +++ b/koch.nim @@ -266,7 +266,7 @@ proc findStartNim: string = # If these fail, we try to build nim with the "build.(sh|bat)" script. let (nim, ok) = findNimImpl() if ok: return nim - when defined(Posix): + when defined(posix): const buildScript = "build.sh" if fileExists(buildScript): if tryExec("./" & buildScript): return "bin" / nim diff --git a/lib/posix/posix.nim b/lib/posix/posix.nim index d66597073f301..af3b7ea23ab6f 100644 --- a/lib/posix/posix.nim +++ b/lib/posix/posix.nim @@ -189,7 +189,7 @@ proc posix_fadvise*(a1: cint, a2, a3: Off, a4: cint): cint {. proc posix_fallocate*(a1: cint, a2, a3: Off): cint {. importc, header: "".} -when not defined(haiku) and not defined(OpenBSD): +when not defined(haiku) and not defined(openbsd): proc fmtmsg*(a1: int, a2: cstring, a3: cint, a4, a5, a6: cstring): cint {.importc, header: "".} diff --git a/lib/pure/fenv.nim b/lib/pure/fenv.nim index 57fb40449c36c..ddb6a1a0c3551 100644 --- a/lib/pure/fenv.nim +++ b/lib/pure/fenv.nim @@ -12,7 +12,7 @@ ## The types, vars and procs are bindings for the C standard library ## [](https://en.cppreference.com/w/c/numeric/fenv) header. -when defined(Posix) and not defined(genode): +when defined(posix) and not defined(genode): {.passl: "-lm".} var diff --git a/lib/pure/includes/oserr.nim b/lib/pure/includes/oserr.nim index 8938d7f733438..94891ccbab0b1 100644 --- a/lib/pure/includes/oserr.nim +++ b/lib/pure/includes/oserr.nim @@ -39,7 +39,7 @@ proc osErrorMsg*(errorCode: OSErrorCode): string = result = "" when defined(nimscript): discard - elif defined(Windows): + elif defined(windows): if errorCode != OSErrorCode(0'i32): when useWinUnicode: var msgbuf: WideCString diff --git a/lib/pure/math.nim b/lib/pure/math.nim index 4a13eefcbd903..74a98e655bc6d 100644 --- a/lib/pure/math.nim +++ b/lib/pure/math.nim @@ -122,7 +122,7 @@ func fac*(n: int): int = {.push checks: off, line_dir: off, stack_trace: off.} -when defined(Posix) and not defined(genode): +when defined(posix) and not defined(genode): {.passl: "-lm".} const diff --git a/lib/pure/nativesockets.nim b/lib/pure/nativesockets.nim index fe890e7214ca2..833294239477f 100644 --- a/lib/pure/nativesockets.nim +++ b/lib/pure/nativesockets.nim @@ -19,7 +19,7 @@ import std/private/since when hostOS == "solaris": {.passl: "-lsocket -lnsl".} -const useWinVersion = defined(Windows) or defined(nimdoc) +const useWinVersion = defined(windows) or defined(nimdoc) when useWinVersion: import winlean @@ -748,6 +748,6 @@ proc accept*(fd: SocketHandle, inheritable = defined(nimInheritHandles)): (Socke else: return (sock, $inet_ntoa(sockAddress.sin_addr)) -when defined(Windows): +when defined(windows): var wsa: WSAData if wsaStartup(0x0101'i16, addr wsa) != 0: raiseOSError(osLastError()) diff --git a/lib/pure/net.nim b/lib/pure/net.nim index 0519fcede92c5..a7025bd970d48 100644 --- a/lib/pure/net.nim +++ b/lib/pure/net.nim @@ -92,7 +92,7 @@ import ssl_config export nativesockets.Port, nativesockets.`$`, nativesockets.`==` export Domain, SockType, Protocol -const useWinVersion = defined(Windows) or defined(nimdoc) +const useWinVersion = defined(windows) or defined(nimdoc) const defineSsl = defined(ssl) or defined(nimdoc) when useWinVersion: diff --git a/lib/pure/os.nim b/lib/pure/os.nim index ad0d9949b1b84..b900546a010e8 100644 --- a/lib/pure/os.nim +++ b/lib/pure/os.nim @@ -1408,7 +1408,7 @@ proc setCurrentDir*(newDir: string) {.inline, tags: [], noWeirdTarget.} = ## * `getConfigDir proc <#getConfigDir>`_ ## * `getTempDir proc <#getTempDir>`_ ## * `getCurrentDir proc <#getCurrentDir>`_ - when defined(Windows): + when defined(windows): when useWinUnicode: if setCurrentDirectoryW(newWideCString(newDir)) == 0'i32: raiseOSError(osLastError(), newDir) @@ -1512,7 +1512,7 @@ proc normalizedPath*(path: string): string {.rtl, extern: "nos$1", tags: [].} = assert normalizedPath("a///b//..//c///d") == "a/c/d" result = pathnorm.normalizePath(path) -when defined(Windows) and not weirdTarget: +when defined(windows) and not weirdTarget: proc openHandle(path: string, followSymlink=true, writeAccess=false): Handle = var flags = FILE_FLAG_BACKUP_SEMANTICS or FILE_ATTRIBUTE_NORMAL if not followSymlink: @@ -1545,7 +1545,7 @@ proc sameFile*(path1, path2: string): bool {.rtl, extern: "nos$1", ## ## See also: ## * `sameFileContent proc <#sameFileContent,string,string>`_ - when defined(Windows): + when defined(windows): var success = true var f1 = openHandle(path1) var f2 = openHandle(path2) @@ -1700,7 +1700,7 @@ proc createSymlink*(src, dest: string) {.noWeirdTarget.} = ## * `createHardlink proc <#createHardlink,string,string>`_ ## * `expandSymlink proc <#expandSymlink,string>`_ - when defined(Windows): + when defined(windows): const SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE = 2 # allows anyone with developer mode on to create a link let flag = dirExists(src).int32 or SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE @@ -1802,7 +1802,7 @@ proc copyFile*(source, dest: string, options = {cfSymlinkFollow}) {.rtl, let isSymlink = source.symlinkExists if isSymlink and (cfSymlinkIgnore in options or defined(windows)): return - when defined(Windows): + when defined(windows): when useWinUnicode: let s = newWideCString(source) let d = newWideCString(dest) @@ -1866,7 +1866,7 @@ proc copyFileToDir*(source, dir: string, options = {cfSymlinkFollow}) raise newException(ValueError, "dest is empty") copyFile(source, dir / source.lastPathPart, options) -when not declared(ENOENT) and not defined(Windows): +when not declared(ENOENT) and not defined(windows): when NoFakeVars: when not defined(haiku): const ENOENT = cint(2) # 2 on most systems including Solaris @@ -1875,7 +1875,7 @@ when not declared(ENOENT) and not defined(Windows): else: var ENOENT {.importc, header: "".}: cint -when defined(Windows) and not weirdTarget: +when defined(windows) and not weirdTarget: when useWinUnicode: template deleteFile(file: untyped): untyped = deleteFileW(file) template setFileAttributes(file, attrs: untyped): untyped = @@ -1899,7 +1899,7 @@ proc tryRemoveFile*(file: string): bool {.rtl, extern: "nos$1", tags: [WriteDirE ## * `removeFile proc <#removeFile,string>`_ ## * `moveFile proc <#moveFile,string,string>`_ result = true - when defined(Windows): + when defined(windows): when useWinUnicode: let f = newWideCString(file) else: @@ -1940,7 +1940,7 @@ proc tryMoveFSObject(source, dest: string): bool {.noWeirdTarget.} = ## Returns false in case of `EXDEV` error. ## In case of other errors `OSError` is raised. ## Returns true in case of success. - when defined(Windows): + when defined(windows): when useWinUnicode: let s = newWideCString(source) let d = newWideCString(dest) @@ -2559,7 +2559,7 @@ proc createHardlink*(src, dest: string) {.noWeirdTarget.} = ## ## See also: ## * `createSymlink proc <#createSymlink,string,string>`_ - when defined(Windows): + when defined(windows): when useWinUnicode: var wSrc = newWideCString(src) var wDst = newWideCString(dest) @@ -2604,7 +2604,7 @@ proc copyFileWithPermissions*(source, dest: string, ## * `moveFile proc <#moveFile,string,string>`_ ## * `copyDirWithPermissions proc <#copyDirWithPermissions,string,string>`_ copyFile(source, dest, options) - when not defined(Windows): + when not defined(windows): try: setFilePermissions(dest, getFilePermissions(source), followSymlinks = (cfSymlinkFollow in options)) @@ -2644,7 +2644,7 @@ proc copyDirWithPermissions*(source, dest: string, ## * `existsOrCreateDir proc <#existsOrCreateDir,string>`_ ## * `createDir proc <#createDir,string>`_ createDir(dest) - when not defined(Windows): + when not defined(windows): try: setFilePermissions(dest, getFilePermissions(source), followSymlinks = false) @@ -3178,7 +3178,7 @@ proc getFileSize*(file: string): BiggestInt {.rtl, extern: "nos$1", close(f) else: raiseOSError(osLastError(), file) -when defined(Windows) or weirdTarget: +when defined(windows) or weirdTarget: type DeviceId* = int32 FileId* = int64 @@ -3210,7 +3210,7 @@ template rawToFormalFileInfo(rawInfo, path, formalInfo): untyped = ## Transforms the native file info structure into the one nim uses. ## 'rawInfo' is either a 'BY_HANDLE_FILE_INFORMATION' structure on Windows, ## or a 'Stat' structure on posix - when defined(Windows): + when defined(windows): template merge(a, b): untyped = a or (b shl 32) formalInfo.id.device = rawInfo.dwVolumeSerialNumber formalInfo.id.file = merge(rawInfo.nFileIndexLow, rawInfo.nFileIndexHigh) @@ -3288,7 +3288,7 @@ proc getFileInfo*(handle: FileHandle): FileInfo {.noWeirdTarget.} = ## * `getFileInfo(path) proc <#getFileInfo,string>`_ # Done: ID, Kind, Size, Permissions, Link Count - when defined(Windows): + when defined(windows): var rawInfo: BY_HANDLE_FILE_INFORMATION # We have to use the super special '_get_osfhandle' call (wrapped above) # To transform the C file descriptor to a native file handle. @@ -3330,7 +3330,7 @@ proc getFileInfo*(path: string, followSymlink = true): FileInfo {.noWeirdTarget. ## See also: ## * `getFileInfo(handle) proc <#getFileInfo,FileHandle>`_ ## * `getFileInfo(file) proc <#getFileInfo,File>`_ - when defined(Windows): + when defined(windows): var handle = openHandle(path, followSymlink) rawInfo: BY_HANDLE_FILE_INFORMATION @@ -3402,7 +3402,7 @@ proc isHidden*(path: string): bool {.noWeirdTarget.} = assert not "".isHidden assert ".foo/".isHidden - when defined(Windows): + when defined(windows): when useWinUnicode: wrapUnary(attributes, getFileAttributesW, path) else: diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim index a4d8409d7e6bd..d730e597b65a9 100644 --- a/lib/pure/osproc.nim +++ b/lib/pure/osproc.nim @@ -522,7 +522,7 @@ when not defined(useNimRtl): template streamAccess(p) = assert poParentStreams notin p.options, "API usage error: stream access not allowed when you use poParentStreams" -when defined(Windows) and not defined(useNimRtl): +when defined(windows) and not defined(useNimRtl): # We need to implement a handle stream for Windows: type FileHandleStream = ref object of StreamObj diff --git a/lib/system/arithm.nim b/lib/system/arithm.nim index 64caddce8d01a..158f4017791c9 100644 --- a/lib/system/arithm.nim +++ b/lib/system/arithm.nim @@ -155,7 +155,7 @@ proc absInt(a: int): int {.compilerproc, inline.} = raiseOverflow() const - asmVersion = defined(I386) and (defined(vcc) or defined(wcc) or + asmVersion = defined(i386) and (defined(vcc) or defined(wcc) or defined(dmc) or defined(gcc) or defined(llvm_gcc)) # my Version of Borland C++Builder does not have # tasm32, which is needed for assembler blocks diff --git a/lib/system/io.nim b/lib/system/io.nim index 31768eb388c86..300e7ea3f7b44 100644 --- a/lib/system/io.nim +++ b/lib/system/io.nim @@ -143,13 +143,13 @@ proc raiseEOF() {.noinline, noreturn.} = proc strerror(errnum: cint): cstring {.importc, header: "".} -when not defined(NimScript): +when not defined(nimscript): var errno {.importc, header: "".}: cint ## error variable EINTR {.importc: "EINTR", header: "".}: cint proc checkErr(f: File) = - when not defined(NimScript): + when not defined(nimscript): if c_ferror(f) != 0: let msg = "errno: " & $errno & " `" & $strerror(errno) & "`" c_clearerr(f) @@ -452,7 +452,7 @@ proc readLine*(f: File, line: var string): bool {.tags: [ReadIOEffect], # likely other io procs need this for correctness. fgetsSuccess = c_fgets(addr line[pos], sp.cint, f) != nil if fgetsSuccess: break - when not defined(NimScript): + when not defined(nimscript): if errno == EINTR: errno = 0 c_clearerr(f) diff --git a/lib/system/syslocks.nim b/lib/system/syslocks.nim index 07fb9cb8abaae..51dbfd3a29b92 100644 --- a/lib/system/syslocks.nim +++ b/lib/system/syslocks.nim @@ -11,7 +11,7 @@ {.push stackTrace: off.} -when defined(Windows): +when defined(windows): type Handle = int diff --git a/lib/wrappers/mysql.nim b/lib/wrappers/mysql.nim index 209f63c21b39b..2fefe4a8b7763 100644 --- a/lib/wrappers/mysql.nim +++ b/lib/wrappers/mysql.nim @@ -11,14 +11,14 @@ when defined(nimHasStyleChecks): {.push styleChecks: off.} -when defined(Unix): +when defined(unix): when defined(macosx): const lib = "(libmysqlclient|libmariadbclient)(|.20|.19|.18|.17|.16|.15).dylib" else: const lib = "(libmysqlclient|libmariadbclient).so(|.20|.19|.18|.17|.16|.15)" -when defined(Windows): +when defined(windows): const lib = "(libmysql.dll|libmariadb.dll)" type diff --git a/lib/wrappers/openssl.nim b/lib/wrappers/openssl.nim index 3c9c92b0d551e..313ce7d199e1e 100644 --- a/lib/wrappers/openssl.nim +++ b/lib/wrappers/openssl.nim @@ -25,7 +25,7 @@ when defined(nimHasStyleChecks): {.push styleChecks: off.} -const useWinVersion = defined(Windows) or defined(nimdoc) +const useWinVersion = defined(windows) or defined(nimdoc) # To force openSSL version use -d:sslVersion=1.0.0 # See: #10281, #10230 diff --git a/testament/categories.nim b/testament/categories.nim index 96449a0239f2e..3a34c51d47f45 100644 --- a/testament/categories.nim +++ b/testament/categories.nim @@ -90,7 +90,7 @@ proc runBasicDLLTest(c, r: var TResults, cat: Category, options: string) = testSpec c, test4 # windows looks in the dir of the exe (yay!): - when not defined(Windows): + when not defined(windows): # posix relies on crappy LD_LIBRARY_PATH (ugh!): const libpathenv = when defined(haiku): "LIBRARY_PATH" else: "LD_LIBRARY_PATH" diff --git a/tests/manyloc/keineschweine/dependencies/enet/enet.nim b/tests/manyloc/keineschweine/dependencies/enet/enet.nim index 02ebef5956c86..5dee6ae9c768d 100644 --- a/tests/manyloc/keineschweine/dependencies/enet/enet.nim +++ b/tests/manyloc/keineschweine/dependencies/enet/enet.nim @@ -265,7 +265,7 @@ const ENET_PEER_RELIABLE_WINDOW_SIZE = 0x1000 ENET_PEER_FREE_RELIABLE_WINDOWS = 8 -when defined(Linux) or true: +when defined(linux) or true: import posix const ENET_SOCKET_NULL*: cint = -1 @@ -295,7 +295,7 @@ when defined(Linux) or true: template ENET_SOCKETSET_CHECK*(sockset, socket: untyped): untyped = FD_ISSET(socket, addr((sockset))) -when defined(Windows): +when defined(windows): ## put the content of win32.h in here diff --git a/tests/manyloc/keineschweine/lib/glut.nim b/tests/manyloc/keineschweine/lib/glut.nim index 44a2907286ecc..de9a974563655 100644 --- a/tests/manyloc/keineschweine/lib/glut.nim +++ b/tests/manyloc/keineschweine/lib/glut.nim @@ -93,7 +93,7 @@ const GLUT_NORMAL* = 0 GLUT_OVERLAY* = 1 -when defined(Windows): +when defined(windows): const # Stroke font constants (use these in GLUT program). GLUT_STROKE_ROMAN* = cast[Pointer](0) GLUT_STROKE_MONO_ROMAN* = cast[Pointer](1) # Bitmap font constants (use these in GLUT program). diff --git a/tests/niminaction/Chapter8/sdl/sdl.nim b/tests/niminaction/Chapter8/sdl/sdl.nim index 7ba154cae69ba..212f7b02282b6 100644 --- a/tests/niminaction/Chapter8/sdl/sdl.nim +++ b/tests/niminaction/Chapter8/sdl/sdl.nim @@ -1,8 +1,8 @@ -when defined(Windows): +when defined(windows): const libName* = "SDL2.dll" -elif defined(Linux) or defined(freebsd) or defined(netbsd): +elif defined(linux) or defined(freebsd) or defined(netbsd): const libName* = "libSDL2.so" -elif defined(MacOsX): +elif defined(macosx): const libName* = "libSDL2.dylib" elif defined(openbsd): const libName* = "libSDL2.so.0.6" diff --git a/tests/stdlib/tos.nim b/tests/stdlib/tos.nim index cf6fa20fa5d26..db64f6254d301 100644 --- a/tests/stdlib/tos.nim +++ b/tests/stdlib/tos.nim @@ -353,7 +353,7 @@ block absolutePath: doAssertRaises(ValueError): discard absolutePath("a", "b") doAssert absolutePath("a") == getCurrentDir() / "a" doAssert absolutePath("a", "/b") == "/b" / "a" - when defined(Posix): + when defined(posix): doAssert absolutePath("a", "/b/") == "/b" / "a" doAssert absolutePath("a", "/b/c") == "/b/c" / "a" doAssert absolutePath("/a", "b/") == "/a" @@ -610,7 +610,7 @@ block: # normalizePathEnd doAssert "//".normalizePathEnd(false) == "/" doAssert "foo.bar//".normalizePathEnd == "foo.bar" doAssert "bar//".normalizePathEnd(trailingSep = true) == "bar/" - when defined(Windows): + when defined(windows): doAssert r"C:\foo\\".normalizePathEnd == r"C:\foo" doAssert r"C:\foo".normalizePathEnd(trailingSep = true) == r"C:\foo\" # this one is controversial: we could argue for returning `D:\` instead, diff --git a/tests/stdlib/tosprocterminate.nim b/tests/stdlib/tosprocterminate.nim index c02e0a8da8725..8e9041b81c0d0 100644 --- a/tests/stdlib/tosprocterminate.nim +++ b/tests/stdlib/tosprocterminate.nim @@ -6,7 +6,7 @@ discard """ import os, osproc, times, std / monotimes -when defined(Windows): +when defined(windows): const ProgramWhichDoesNotEnd = "notepad" elif defined(openbsd): const ProgramWhichDoesNotEnd = "/bin/cat" diff --git a/tests/template/tmodulealias.nim b/tests/template/tmodulealias.nim index 6681379fbb162..79b5ec9c622eb 100644 --- a/tests/template/tmodulealias.nim +++ b/tests/template/tmodulealias.nim @@ -7,7 +7,7 @@ when defined(windows): else: import posix -when defined(Windows): +when defined(windows): template orig: expr = winlean else: