summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAdam Strzelecki <ono@java.pl>2015-09-04 23:05:22 +0200
committerAdam Strzelecki <ono@java.pl>2015-09-04 23:05:22 +0200
commit5d80548cce84ea62dc8b85c10375f70d037ea4f8 (patch)
tree110db6acbe7cf57031571cbd5f3519bb3ee0a039
parente80465dacf50f260abec30ae57d37b298c93fd83 (diff)
downloadNim-5d80548cce84ea62dc8b85c10375f70d037ea4f8.tar.gz
examples: Trim .nim files trailing whitespace
via OSX: find . -name '*.nim' -exec sed -i '' -E 's/[[:space:]]+$//' {} +
-rw-r--r--examples/allany.nim4
-rw-r--r--examples/c++iface/irrlichtex.nim6
-rw-r--r--examples/cross_calculator/nim_backend/backend.nim10
-rw-r--r--examples/curlex.nim4
-rw-r--r--examples/filterex.nim4
-rw-r--r--examples/htmlrefs.nim18
-rw-r--r--examples/htmltitle.nim8
-rw-r--r--examples/httpserver2.nim6
-rw-r--r--examples/maximum.nim12
-rw-r--r--examples/parsecfgex.nim4
-rw-r--r--examples/sdlex.nim104
-rw-r--r--examples/statcsv.nim2
-rw-r--r--examples/talk/tags.nim2
-rw-r--r--examples/tunit.nim94
-rw-r--r--web/snippets/snippet1.nim4
15 files changed, 141 insertions, 141 deletions
diff --git a/examples/allany.nim b/examples/allany.nim
index de36a1d9b..52a794204 100644
--- a/examples/allany.nim
+++ b/examples/allany.nim
@@ -18,9 +18,9 @@ template any(container, cond: expr): expr {.immediate.} =
         break
     result
 
-if all("mystring", {'a'..'z'}.contains) and any("myohmy", 'y'.`==`): 
+if all("mystring", {'a'..'z'}.contains) and any("myohmy", 'y'.`==`):
   echo "works"
-else: 
+else:
   echo "does not work"
 
 
diff --git a/examples/c++iface/irrlichtex.nim b/examples/c++iface/irrlichtex.nim
index 4dd1d79ee..373a78ce7 100644
--- a/examples/c++iface/irrlichtex.nim
+++ b/examples/c++iface/irrlichtex.nim
@@ -18,13 +18,13 @@ type
   TDimension2d {.final, header: irr, importc: "dimension2d".} = object
   Tvector3df {.final, header: irr, importc: "vector3df".} = object
   TColor {.final, header: irr, importc: "SColor".} = object
-  
+
   TIrrlichtDevice {.final, header: irr, importc: "IrrlichtDevice".} = object
   TIVideoDriver {.final, header: irr, importc: "IVideoDriver".} = object
   TISceneManager {.final, header: irr, importc: "ISceneManager".} = object
   TIGUIEnvironment {.final, header: irr, importc: "IGUIEnvironment".} = object
   TIAnimatedMesh {.final, header: irr, importc: "IAnimatedMesh".} = object
-  TIAnimatedMeshSceneNode {.final, header: irr, 
+  TIAnimatedMeshSceneNode {.final, header: irr,
     importc: "IAnimatedMeshSceneNode".} = object
   TITexture {.final, header: irr, importc: "ITexture".} = object
 
@@ -100,7 +100,7 @@ var node = smgr.addAnimatedMeshSceneNode(mesh)
 if node != nil:
   #node->setMaterialFlag(EMF_LIGHTING, false)
   #node->setMD2Animation(scene::EMAT_STAND)
-  node.setMaterialTexture(0, 
+  node.setMaterialTexture(0,
     driver.getTexture(
       "/home/andreas/download/irrlicht-1.7.2/media/media/sydney.bmp"))
 
diff --git a/examples/cross_calculator/nim_backend/backend.nim b/examples/cross_calculator/nim_backend/backend.nim
index ffa4311f9..c8684581c 100644
--- a/examples/cross_calculator/nim_backend/backend.nim
+++ b/examples/cross_calculator/nim_backend/backend.nim
@@ -1,5 +1,5 @@
-# Backend for the different user interfaces.

-

-proc myAdd*(x, y: int): int {.cdecl, exportc.} = 

-  result = x + y

-

+# Backend for the different user interfaces.
+
+proc myAdd*(x, y: int): int {.cdecl, exportc.} =
+  result = x + y
+
diff --git a/examples/curlex.nim b/examples/curlex.nim
index 017956818..21786a6ee 100644
--- a/examples/curlex.nim
+++ b/examples/curlex.nim
@@ -1,8 +1,8 @@
-import 
+import
   libcurl
 
 var hCurl = easy_init()
-if hCurl != nil: 
+if hCurl != nil:
   discard easy_setopt(hCurl, OPT_VERBOSE, true)
   discard easy_setopt(hCurl, OPT_URL, "http://nim-lang.org/")
   discard easy_perform(hCurl)
diff --git a/examples/filterex.nim b/examples/filterex.nim
index 3713f4b64..d9bfb6782 100644
--- a/examples/filterex.nim
+++ b/examples/filterex.nim
@@ -1,6 +1,6 @@
 #! stdtmpl | standard
 #proc generateHTMLPage(title, currentTab, content: string,
-#                      tabs: openArray[string]): string = 
+#                      tabs: openArray[string]): string =
 #  result = ""
 <head><title>$title</title></head>
 <body>
@@ -8,7 +8,7 @@
     <ul>
   #for tab in items(tabs):
     #if currentTab == tab:
-    <li><a id="selected" 
+    <li><a id="selected"
     #else:
     <li><a
     #end if
diff --git a/examples/htmlrefs.nim b/examples/htmlrefs.nim
index 5364d61b6..394932773 100644
--- a/examples/htmlrefs.nim
+++ b/examples/htmlrefs.nim
@@ -4,11 +4,11 @@
 
 import os, streams, parsexml, strutils
 
-proc `=?=` (a, b: string): bool = 
+proc `=?=` (a, b: string): bool =
   # little trick: define our own comparator that ignores case
   return cmpIgnoreCase(a, b) == 0
 
-if paramCount() < 1: 
+if paramCount() < 1:
   quit("Usage: htmlrefs filename[.html]")
 
 var links = 0 # count the number of links
@@ -21,17 +21,17 @@ next(x) # get first event
 block mainLoop:
   while true:
     case x.kind
-    of xmlElementOpen: 
+    of xmlElementOpen:
       # the <a href = "xyz"> tag we are interested in always has an attribute,
       # thus we search for ``xmlElementOpen`` and not for ``xmlElementStart``
-      if x.elementName =?= "a": 
+      if x.elementName =?= "a":
         x.next()
-        if x.kind == xmlAttribute: 
+        if x.kind == xmlAttribute:
           if x.attrKey =?= "href":
             var link = x.attrValue
             inc(links)
             # skip until we have an ``xmlElementClose`` event
-            while true: 
+            while true:
               x.next()
               case x.kind
               of xmlEof: break mainLoop
@@ -40,14 +40,14 @@ block mainLoop:
             x.next() # skip ``xmlElementClose``
             # now we have the description for the ``a`` element
             var desc = ""
-            while x.kind == xmlCharData: 
+            while x.kind == xmlCharData:
               desc.add(x.charData)
               x.next()
             echo(desc & ": " & link)
       else:
-        x.next()      
+        x.next()
     of xmlEof: break # end of file reached
-    of xmlError: 
+    of xmlError:
       echo(errorMsg(x))
       x.next()
     else: x.next() # skip other events
diff --git a/examples/htmltitle.nim b/examples/htmltitle.nim
index 7e66fabaa..96bfc7d91 100644
--- a/examples/htmltitle.nim
+++ b/examples/htmltitle.nim
@@ -15,11 +15,11 @@ open(x, s, filename)
 while true:
   x.next()
   case x.kind
-  of xmlElementStart: 
-    if cmpIgnoreCase(x.elementName, "title") == 0: 
+  of xmlElementStart:
+    if cmpIgnoreCase(x.elementName, "title") == 0:
       var title = ""
       x.next()  # skip "<title>"
-      while x.kind == xmlCharData: 
+      while x.kind == xmlCharData:
         title.add(x.charData)
         x.next()
       if x.kind == xmlElementEnd and cmpIgnoreCase(x.elementName, "title") == 0:
@@ -27,7 +27,7 @@ while true:
         quit(0) # Success!
       else:
         echo(x.errorMsgExpected("/title"))
-  
+
   of xmlEof: break # end of file reached
   else: discard # ignore other events
 
diff --git a/examples/httpserver2.nim b/examples/httpserver2.nim
index 13fea9e21..050684d3e 100644
--- a/examples/httpserver2.nim
+++ b/examples/httpserver2.nim
@@ -90,7 +90,7 @@ proc serveFile(client: Socket, filename: string) =
 
 # ------------------ CGI execution -------------------------------------------
 
-proc executeCgi(server: var TServer, client: Socket, path, query: string, 
+proc executeCgi(server: var TServer, client: Socket, path, query: string,
                 meth: TRequestMethod) =
   var env = newStringTable(modeCaseInsensitive)
   var contentLength = -1
@@ -123,12 +123,12 @@ proc executeCgi(server: var TServer, client: Socket, path, query: string,
   send(client, "HTTP/1.0 200 OK" & wwwNL)
 
   var process = startProcess(command=path, env=env)
- 
+
   var job: TJob
   job.process = process
   job.client = client
   server.job.add(job)
- 
+
   if meth == reqPost:
     # get from client and post to CGI program:
     var buf = alloc(contentLength)
diff --git a/examples/maximum.nim b/examples/maximum.nim
index ac6160f76..aa3fe375a 100644
--- a/examples/maximum.nim
+++ b/examples/maximum.nim
@@ -1,6 +1,6 @@
-# Test high level features

-

-import strutils

-

-echo "Give a list of numbers (separated by spaces): "

-stdin.readLine.split.map(parseInt).max.`$`.echo(" is the maximum!")

+# Test high level features
+
+import strutils
+
+echo "Give a list of numbers (separated by spaces): "
+stdin.readLine.split.map(parseInt).max.`$`.echo(" is the maximum!")
diff --git a/examples/parsecfgex.nim b/examples/parsecfgex.nim
index 0f37a0378..0fa03ffb5 100644
--- a/examples/parsecfgex.nim
+++ b/examples/parsecfgex.nim
@@ -1,7 +1,7 @@
 
 import
   os, parsecfg, strutils, streams
-  
+
 var f = newFileStream(paramStr(1), fmRead)
 if f != nil:
   var p: CfgParser
@@ -9,7 +9,7 @@ if f != nil:
   while true:
     var e = next(p)
     case e.kind
-    of cfgEof: 
+    of cfgEof:
       echo("EOF!")
       break
     of cfgSectionStart:   ## a ``[section]`` has been parsed
diff --git a/examples/sdlex.nim b/examples/sdlex.nim
index 3dd474d8e..7a4ebf3db 100644
--- a/examples/sdlex.nim
+++ b/examples/sdlex.nim
@@ -1,52 +1,52 @@
-# Test the SDL interface:

-

-import

-  sdl, sdl_image, colors

-

-var

-  screen, greeting: PSurface

-  r: TRect

-  event: TEvent

-  bgColor = colChocolate.int32

-

-if init(INIT_VIDEO) != 0:

-  quit "SDL failed to initialize!"

-

-screen = setVideoMode(640, 480, 16, SWSURFACE or ANYFORMAT)

-if screen.isNil:

-  quit($sdl.getError())

-

-greeting = imgLoad("tux.png")

-if greeting.isNil:

-  echo "Failed to load tux.png"

-else:

-  ## convert the image to alpha and free the old one

-  var s = greeting.displayFormatAlpha()

-  swap(greeting, s)

-  s.freeSurface()

-

-r.x = 0

-r.y = 0

-

-block game_loop:

-  while true:

-    

-    while pollEvent(addr event) > 0:

-      case event.kind

-      of QUITEV:

-        break game_loop

-      of KEYDOWN:

-        if evKeyboard(addr event).keysym.sym == K_ESCAPE:

-          break game_loop

-      else:

-        discard

-    

-    discard fillRect(screen, nil, bgColor) 

-    discard blitSurface(greeting, nil, screen, addr r)

-    discard flip(screen)

-

-greeting.freeSurface()

-screen.freeSurface()

-sdl.quit()

-

-## fowl wuz here 10/2012
\ No newline at end of file
+# Test the SDL interface:
+
+import
+  sdl, sdl_image, colors
+
+var
+  screen, greeting: PSurface
+  r: TRect
+  event: TEvent
+  bgColor = colChocolate.int32
+
+if init(INIT_VIDEO) != 0:
+  quit "SDL failed to initialize!"
+
+screen = setVideoMode(640, 480, 16, SWSURFACE or ANYFORMAT)
+if screen.isNil:
+  quit($sdl.getError())
+
+greeting = imgLoad("tux.png")
+if greeting.isNil:
+  echo "Failed to load tux.png"
+else:
+  ## convert the image to alpha and free the old one
+  var s = greeting.displayFormatAlpha()
+  swap(greeting, s)
+  s.freeSurface()
+
+r.x = 0
+r.y = 0
+
+block game_loop:
+  while true:
+
+    while pollEvent(addr event) > 0:
+      case event.kind
+      of QUITEV:
+        break game_loop
+      of KEYDOWN:
+        if evKeyboard(addr event).keysym.sym == K_ESCAPE:
+          break game_loop
+      else:
+        discard
+
+    discard fillRect(screen, nil, bgColor)
+    discard blitSurface(greeting, nil, screen, addr r)
+    discard flip(screen)
+
+greeting.freeSurface()
+screen.freeSurface()
+sdl.quit()
+
+## fowl wuz here 10/2012
diff --git a/examples/statcsv.nim b/examples/statcsv.nim
index cd1de62af..f2cf809e2 100644
--- a/examples/statcsv.nim
+++ b/examples/statcsv.nim
@@ -28,7 +28,7 @@ while readRow(x):
       for i in 0..x.row.len-1: header[i] = "Col " & $(i+1)
   else:
     # data line:
-    for i in 0..x.row.len-1: 
+    for i in 0..x.row.len-1:
       push(res[i], parseFloat(x.row[i]))
 x.close()
 
diff --git a/examples/talk/tags.nim b/examples/talk/tags.nim
index d47b09e07..12b9a08c3 100644
--- a/examples/talk/tags.nim
+++ b/examples/talk/tags.nim
@@ -1,7 +1,7 @@
 
 template htmlTag(tag: expr) {.immediate.} =
   proc tag(): string = "<" & astToStr(tag) & ">"
-  
+
 htmlTag(br)
 htmlTag(html)
 
diff --git a/examples/tunit.nim b/examples/tunit.nim
index d0e975119..d7b1fcbbd 100644
--- a/examples/tunit.nim
+++ b/examples/tunit.nim
@@ -1,47 +1,47 @@
-import

-  unittest, macros

-

-var

-    a = 1

-    b = 22

-    c = 1

-    d = 3

-

-suite "my suite":

-  setup:

-    echo "suite setup"

-    var testVar = "from setup"

-    

-  teardown:

-    echo "suite teardown"

-

-  test "first suite test":

-    testVar = "modified"

-    echo "test var: " & testVar

-    check a > b

-

-  test "second suite test":

-    echo "test var: " & testVar

-

-proc foo: bool =

-  echo "running foo"

-  return true

-

-proc err =

-  raise newException(EArithmetic, "some exception")

-

-test "final test":

-  echo "inside suite-less test"

-

-  check:

-    a == c

-    foo()

-    d > 10

-

-test "arithmetic failure":

-  expect(EArithmetic):

-    err()

-

-  expect(EArithmetic, ESystem):

-    discard foo()

-

+import
+  unittest, macros
+
+var
+    a = 1
+    b = 22
+    c = 1
+    d = 3
+
+suite "my suite":
+  setup:
+    echo "suite setup"
+    var testVar = "from setup"
+
+  teardown:
+    echo "suite teardown"
+
+  test "first suite test":
+    testVar = "modified"
+    echo "test var: " & testVar
+    check a > b
+
+  test "second suite test":
+    echo "test var: " & testVar
+
+proc foo: bool =
+  echo "running foo"
+  return true
+
+proc err =
+  raise newException(EArithmetic, "some exception")
+
+test "final test":
+  echo "inside suite-less test"
+
+  check:
+    a == c
+    foo()
+    d > 10
+
+test "arithmetic failure":
+  expect(EArithmetic):
+    err()
+
+  expect(EArithmetic, ESystem):
+    discard foo()
+
diff --git a/web/snippets/snippet1.nim b/web/snippets/snippet1.nim
index 85cb98142..b0895e0c0 100644
--- a/web/snippets/snippet1.nim
+++ b/web/snippets/snippet1.nim
@@ -1,4 +1,4 @@
 import strutils
-echo "Give a list of integers (separated by spaces): ", 
+echo "Give a list of integers (separated by spaces): ",
      stdin.readLine.split.each(parseInt).max,
-     " is the maximum!"

+     " is the maximum!"