Skip to content

Commit

Permalink
use lowercase --define switches (#17283)
Browse files Browse the repository at this point in the history
  • Loading branch information
ringabout authored Mar 7, 2021
1 parent b8c04bd commit 0e3ea16
Show file tree
Hide file tree
Showing 21 changed files with 45 additions and 45 deletions.
2 changes: 1 addition & 1 deletion koch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/posix/posix.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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: "<fcntl.h>".}

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: "<fmtmsg.h>".}

Expand Down
2 changes: 1 addition & 1 deletion lib/pure/fenv.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
## The types, vars and procs are bindings for the C standard library
## [<fenv.h>](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
Expand Down
2 changes: 1 addition & 1 deletion lib/pure/includes/oserr.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/pure/math.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/pure/nativesockets.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())
2 changes: 1 addition & 1 deletion lib/pure/net.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
34 changes: 17 additions & 17 deletions lib/pure/os.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -1875,7 +1875,7 @@ when not declared(ENOENT) and not defined(Windows):
else:
var ENOENT {.importc, header: "<errno.h>".}: 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 =
Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion lib/pure/osproc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/system/arithm.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions lib/system/io.nim
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ proc raiseEOF() {.noinline, noreturn.} =

proc strerror(errnum: cint): cstring {.importc, header: "<string.h>".}

when not defined(NimScript):
when not defined(nimscript):
var
errno {.importc, header: "<errno.h>".}: cint ## error variable
EINTR {.importc: "EINTR", header: "<errno.h>".}: 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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/system/syslocks.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

{.push stackTrace: off.}

when defined(Windows):
when defined(windows):
type
Handle = int

Expand Down
4 changes: 2 additions & 2 deletions lib/wrappers/mysql.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/wrappers/openssl.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion testament/categories.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions tests/manyloc/keineschweine/dependencies/enet/enet.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion tests/manyloc/keineschweine/lib/glut.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
6 changes: 3 additions & 3 deletions tests/niminaction/Chapter8/sdl/sdl.nim
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
4 changes: 2 additions & 2 deletions tests/stdlib/tos.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tests/stdlib/tosprocterminate.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion tests/template/tmodulealias.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ when defined(windows):
else:
import posix

when defined(Windows):
when defined(windows):
template orig: expr =
winlean
else:
Expand Down

0 comments on commit 0e3ea16

Please sign in to comment.