summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <andreas@andreas-desktop>2010-01-05 00:34:15 +0100
committerAndreas Rumpf <andreas@andreas-desktop>2010-01-05 00:34:15 +0100
commita8303679960a13aa9ddd1f2fa44c2e4f9a12f071 (patch)
tree69cc1b3d8c501eb3d7fddaffe3d0e4e06bd5c82e
parenta58a2f3823c33104992dc0e4129fa53e66a18f44 (diff)
downloadNim-a8303679960a13aa9ddd1f2fa44c2e4f9a12f071.tar.gz
further development of httpserver
-rwxr-xr-xexamples/allany.nim17
-rwxr-xr-x[-rw-r--r--]lib/devel/httpserver.nim92
-rwxr-xr-x[-rw-r--r--]lib/newwrap/cairo/cairo.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/cairo/cairoft.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/cairo/cairowin32.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/cairo/cairoxlib.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/gtk/atk.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/gtk/gdk2.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/gtk/gdk2pixbuf.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/gtk/gdkglext.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/gtk/glib2.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/gtk/gtk2.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/gtk/gtkglext.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/gtk/gtkhtml.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/gtk/libglade2.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/gtk/pango.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/gtk/pangoutils.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/libcurl.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/lua/lauxlib.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/lua/lua.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/lua/lualib.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/mysql.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/opengl/gl.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/opengl/glext.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/opengl/glu.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/opengl/glut.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/opengl/glx.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/opengl/wingl.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/pcre/pcre.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/postgres.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/sdl/sdl.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/sdl/sdl_gfx.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/sdl/sdl_image.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/sdl/sdl_mixer.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/sdl/sdl_mixer_nosmpeg.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/sdl/sdl_net.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/sdl/sdl_ttf.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/sdl/smpeg.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/sqlite3.nim0
-rwxr-xr-x[-rw-r--r--]lib/newwrap/tcl.nim0
-rwxr-xr-x[-rw-r--r--]lib/pure/sockets.nim2
-rwxr-xr-x[-rw-r--r--]llvm/llvm.nim0
-rwxr-xr-x[-rw-r--r--]llvm/llvm_orig.nim0
-rwxr-xr-x[-rw-r--r--]rod/llvmtype.nim0
-rwxr-xr-xrod/scanner.nim10
-rwxr-xr-xtests/tfinally.nim2
-rwxr-xr-x[-rw-r--r--]tests/tmatrix.nim8
47 files changed, 102 insertions, 29 deletions
diff --git a/examples/allany.nim b/examples/allany.nim
new file mode 100755
index 000000000..4747ce0d6
--- /dev/null
+++ b/examples/allany.nim
@@ -0,0 +1,17 @@
+# All and any
+
+template all(container, cond: expr): expr =
+  block:
+    var result = true
+    for item in items(container):
+      if not cond(item):
+        result = false
+        break
+    result
+
+if all("mystring", {'a'..'z'}.contains): 
+  echo "works"
+else: 
+  echo "does not work"
+
+
diff --git a/lib/devel/httpserver.nim b/lib/devel/httpserver.nim
index ca1e315f0..285dadf0a 100644..100755
--- a/lib/devel/httpserver.nim
+++ b/lib/devel/httpserver.nim
@@ -134,14 +134,6 @@ proc executeCgi(client: TSocket, path, query: string, meth: TRequestMethod) =
 
 # --------------- Server Setup -----------------------------------------------
 
-proc startup(): tuple[socket: TSocket, port: TPort] =
-  var s = socket(AF_INET)
-  if s == InvalidSocket: OSError()
-  bindAddr(s)
-  listen(s)
-  result.socket = s
-  result.port = getSockName(s)
-
 proc acceptRequest(client: TSocket) =
   var cgi = false
   var query = ""
@@ -181,16 +173,80 @@ proc acceptRequest(client: TSocket) =
     else:
       executeCgi(client, path, query, meth)
 
-proc main =  
-  var (server, port) = startup()
-  echo("httpserver running on port ", int16(port))
+type
+  TServer* = object
+    socket: TSocket
+    port: TPort
+    client*: TSocket      ## the socket to write the file data to
+    path*, query*: string ## path and query the client requested
+    
+proc open*(s: var TServer, port = TPort(0)) = 
+  ## creates a new server at port `port`. If ``port == 0`` a free port is
+  ## aquired that can be accessed later by the ``port`` proc.
+  s.socket = socket(AF_INET)
+  if s.socket == InvalidSocket: OSError()
+  bindAddr(s.socket)
+  listen(s.socket)
+  s.port = getSockName(s.socket)
+  s.client = InvalidSocket
+  s.path = ""
+  s.query = ""
+  
+proc port*(s: var TServer): TPort = 
+  ## get the port number the server has aquired.
+  result = s.port
   
-  while true:
-    var client = accept(server)
-    if client == InvalidSocket: OSError()
-    acceptRequest(client)
-    close(client)
-  close(server)
+proc next*(s: var TServer) = 
+  ## proceed to the first/next request.
+  s.client = accept(s.socket)
+  headers(s.client, "")
+  var buf = ""
+  discard recvLine(s.client, buf)
+  var data = buf.split()
+  if cmpIgnoreCase(data[0], "GET") == 0:
+    var q = find(data[1], '?')
+    if q >= 0:
+      s.query = data[1].copy(q+1)
+      s.path = data[1].copy(0, q-1)
+    else:
+      s.query = ""
+      s.path = data[1]
+  else:
+    unimplemented(s.client)
+
+proc close*(s: TServer) =
+  close(s.socket)
+
+proc run*(handleRequest: proc (client: TSocket, path, query: string): bool, 
+          port = TPort(0)) =
+  ## encapsulates the server object and main loop
+  var s: TServer
+  open(s, port)
+  echo("httpserver running on port ", s.port)
+  while true: 
+    next(s)
+    if handleRequest(s.client, s.path, s.query): break
+    close(s.client)
+  close(s.socket)
+
+when false:
+  proc main =  
+    var (server, port) = startup()
+    echo("httpserver running on port ", int16(port))
+    
+    while true:
+      var client = accept(server)
+      if client == InvalidSocket: OSError()
+      acceptRequest(client)
+      close(client)
+    close(server)
 
 when isMainModule:
-  main()
+  var counter = 0
+  proc handleRequest(client: TSocket, path, query: string): bool {.procvar.} =
+    inc(counter)
+    client.send("Hallo, Andreas for the $#th time." % $counter & wwwNL)
+    return false # do not stop processing
+  
+  run(handleRequest)
+
diff --git a/lib/newwrap/cairo/cairo.nim b/lib/newwrap/cairo/cairo.nim
index d391b4622..d391b4622 100644..100755
--- a/lib/newwrap/cairo/cairo.nim
+++ b/lib/newwrap/cairo/cairo.nim
diff --git a/lib/newwrap/cairo/cairoft.nim b/lib/newwrap/cairo/cairoft.nim
index e80b9f82c..e80b9f82c 100644..100755
--- a/lib/newwrap/cairo/cairoft.nim
+++ b/lib/newwrap/cairo/cairoft.nim
diff --git a/lib/newwrap/cairo/cairowin32.nim b/lib/newwrap/cairo/cairowin32.nim
index cee034902..cee034902 100644..100755
--- a/lib/newwrap/cairo/cairowin32.nim
+++ b/lib/newwrap/cairo/cairowin32.nim
diff --git a/lib/newwrap/cairo/cairoxlib.nim b/lib/newwrap/cairo/cairoxlib.nim
index a889d7a9b..a889d7a9b 100644..100755
--- a/lib/newwrap/cairo/cairoxlib.nim
+++ b/lib/newwrap/cairo/cairoxlib.nim
diff --git a/lib/newwrap/gtk/atk.nim b/lib/newwrap/gtk/atk.nim
index 9c0a1cb86..9c0a1cb86 100644..100755
--- a/lib/newwrap/gtk/atk.nim
+++ b/lib/newwrap/gtk/atk.nim
diff --git a/lib/newwrap/gtk/gdk2.nim b/lib/newwrap/gtk/gdk2.nim
index c171068d3..c171068d3 100644..100755
--- a/lib/newwrap/gtk/gdk2.nim
+++ b/lib/newwrap/gtk/gdk2.nim
diff --git a/lib/newwrap/gtk/gdk2pixbuf.nim b/lib/newwrap/gtk/gdk2pixbuf.nim
index f22ab345b..f22ab345b 100644..100755
--- a/lib/newwrap/gtk/gdk2pixbuf.nim
+++ b/lib/newwrap/gtk/gdk2pixbuf.nim
diff --git a/lib/newwrap/gtk/gdkglext.nim b/lib/newwrap/gtk/gdkglext.nim
index 41ec0038f..41ec0038f 100644..100755
--- a/lib/newwrap/gtk/gdkglext.nim
+++ b/lib/newwrap/gtk/gdkglext.nim
diff --git a/lib/newwrap/gtk/glib2.nim b/lib/newwrap/gtk/glib2.nim
index 0f1d45340..0f1d45340 100644..100755
--- a/lib/newwrap/gtk/glib2.nim
+++ b/lib/newwrap/gtk/glib2.nim
diff --git a/lib/newwrap/gtk/gtk2.nim b/lib/newwrap/gtk/gtk2.nim
index 3c1eed666..3c1eed666 100644..100755
--- a/lib/newwrap/gtk/gtk2.nim
+++ b/lib/newwrap/gtk/gtk2.nim
diff --git a/lib/newwrap/gtk/gtkglext.nim b/lib/newwrap/gtk/gtkglext.nim
index 779c78ee1..779c78ee1 100644..100755
--- a/lib/newwrap/gtk/gtkglext.nim
+++ b/lib/newwrap/gtk/gtkglext.nim
diff --git a/lib/newwrap/gtk/gtkhtml.nim b/lib/newwrap/gtk/gtkhtml.nim
index a71a24836..a71a24836 100644..100755
--- a/lib/newwrap/gtk/gtkhtml.nim
+++ b/lib/newwrap/gtk/gtkhtml.nim
diff --git a/lib/newwrap/gtk/libglade2.nim b/lib/newwrap/gtk/libglade2.nim
index 47e78e05e..47e78e05e 100644..100755
--- a/lib/newwrap/gtk/libglade2.nim
+++ b/lib/newwrap/gtk/libglade2.nim
diff --git a/lib/newwrap/gtk/pango.nim b/lib/newwrap/gtk/pango.nim
index 1443aba1d..1443aba1d 100644..100755
--- a/lib/newwrap/gtk/pango.nim
+++ b/lib/newwrap/gtk/pango.nim
diff --git a/lib/newwrap/gtk/pangoutils.nim b/lib/newwrap/gtk/pangoutils.nim
index 552362b9a..552362b9a 100644..100755
--- a/lib/newwrap/gtk/pangoutils.nim
+++ b/lib/newwrap/gtk/pangoutils.nim
diff --git a/lib/newwrap/libcurl.nim b/lib/newwrap/libcurl.nim
index 6dc61f112..6dc61f112 100644..100755
--- a/lib/newwrap/libcurl.nim
+++ b/lib/newwrap/libcurl.nim
diff --git a/lib/newwrap/lua/lauxlib.nim b/lib/newwrap/lua/lauxlib.nim
index 13a473687..13a473687 100644..100755
--- a/lib/newwrap/lua/lauxlib.nim
+++ b/lib/newwrap/lua/lauxlib.nim
diff --git a/lib/newwrap/lua/lua.nim b/lib/newwrap/lua/lua.nim
index b702e381c..b702e381c 100644..100755
--- a/lib/newwrap/lua/lua.nim
+++ b/lib/newwrap/lua/lua.nim
diff --git a/lib/newwrap/lua/lualib.nim b/lib/newwrap/lua/lualib.nim
index c2c6cd97b..c2c6cd97b 100644..100755
--- a/lib/newwrap/lua/lualib.nim
+++ b/lib/newwrap/lua/lualib.nim
diff --git a/lib/newwrap/mysql.nim b/lib/newwrap/mysql.nim
index 5f6468faa..5f6468faa 100644..100755
--- a/lib/newwrap/mysql.nim
+++ b/lib/newwrap/mysql.nim
diff --git a/lib/newwrap/opengl/gl.nim b/lib/newwrap/opengl/gl.nim
index 9387b5bc9..9387b5bc9 100644..100755
--- a/lib/newwrap/opengl/gl.nim
+++ b/lib/newwrap/opengl/gl.nim
diff --git a/lib/newwrap/opengl/glext.nim b/lib/newwrap/opengl/glext.nim
index 32871df0e..32871df0e 100644..100755
--- a/lib/newwrap/opengl/glext.nim
+++ b/lib/newwrap/opengl/glext.nim
diff --git a/lib/newwrap/opengl/glu.nim b/lib/newwrap/opengl/glu.nim
index 29edb0df2..29edb0df2 100644..100755
--- a/lib/newwrap/opengl/glu.nim
+++ b/lib/newwrap/opengl/glu.nim
diff --git a/lib/newwrap/opengl/glut.nim b/lib/newwrap/opengl/glut.nim
index 43bee3382..43bee3382 100644..100755
--- a/lib/newwrap/opengl/glut.nim
+++ b/lib/newwrap/opengl/glut.nim
diff --git a/lib/newwrap/opengl/glx.nim b/lib/newwrap/opengl/glx.nim
index 76c052d70..76c052d70 100644..100755
--- a/lib/newwrap/opengl/glx.nim
+++ b/lib/newwrap/opengl/glx.nim
diff --git a/lib/newwrap/opengl/wingl.nim b/lib/newwrap/opengl/wingl.nim
index 7ed78f970..7ed78f970 100644..100755
--- a/lib/newwrap/opengl/wingl.nim
+++ b/lib/newwrap/opengl/wingl.nim
diff --git a/lib/newwrap/pcre/pcre.nim b/lib/newwrap/pcre/pcre.nim
index c2220b4e5..c2220b4e5 100644..100755
--- a/lib/newwrap/pcre/pcre.nim
+++ b/lib/newwrap/pcre/pcre.nim
diff --git a/lib/newwrap/postgres.nim b/lib/newwrap/postgres.nim
index cdb4a7283..cdb4a7283 100644..100755
--- a/lib/newwrap/postgres.nim
+++ b/lib/newwrap/postgres.nim
diff --git a/lib/newwrap/sdl/sdl.nim b/lib/newwrap/sdl/sdl.nim
index 40f2fafff..40f2fafff 100644..100755
--- a/lib/newwrap/sdl/sdl.nim
+++ b/lib/newwrap/sdl/sdl.nim
diff --git a/lib/newwrap/sdl/sdl_gfx.nim b/lib/newwrap/sdl/sdl_gfx.nim
index 39d4c3dc8..39d4c3dc8 100644..100755
--- a/lib/newwrap/sdl/sdl_gfx.nim
+++ b/lib/newwrap/sdl/sdl_gfx.nim
diff --git a/lib/newwrap/sdl/sdl_image.nim b/lib/newwrap/sdl/sdl_image.nim
index 621749e32..621749e32 100644..100755
--- a/lib/newwrap/sdl/sdl_image.nim
+++ b/lib/newwrap/sdl/sdl_image.nim
diff --git a/lib/newwrap/sdl/sdl_mixer.nim b/lib/newwrap/sdl/sdl_mixer.nim
index d4dd2e8df..d4dd2e8df 100644..100755
--- a/lib/newwrap/sdl/sdl_mixer.nim
+++ b/lib/newwrap/sdl/sdl_mixer.nim
diff --git a/lib/newwrap/sdl/sdl_mixer_nosmpeg.nim b/lib/newwrap/sdl/sdl_mixer_nosmpeg.nim
index 571263014..571263014 100644..100755
--- a/lib/newwrap/sdl/sdl_mixer_nosmpeg.nim
+++ b/lib/newwrap/sdl/sdl_mixer_nosmpeg.nim
diff --git a/lib/newwrap/sdl/sdl_net.nim b/lib/newwrap/sdl/sdl_net.nim
index 09318bc79..09318bc79 100644..100755
--- a/lib/newwrap/sdl/sdl_net.nim
+++ b/lib/newwrap/sdl/sdl_net.nim
diff --git a/lib/newwrap/sdl/sdl_ttf.nim b/lib/newwrap/sdl/sdl_ttf.nim
index 410597317..410597317 100644..100755
--- a/lib/newwrap/sdl/sdl_ttf.nim
+++ b/lib/newwrap/sdl/sdl_ttf.nim
diff --git a/lib/newwrap/sdl/smpeg.nim b/lib/newwrap/sdl/smpeg.nim
index 5c9562201..5c9562201 100644..100755
--- a/lib/newwrap/sdl/smpeg.nim
+++ b/lib/newwrap/sdl/smpeg.nim
diff --git a/lib/newwrap/sqlite3.nim b/lib/newwrap/sqlite3.nim
index f2912f05f..f2912f05f 100644..100755
--- a/lib/newwrap/sqlite3.nim
+++ b/lib/newwrap/sqlite3.nim
diff --git a/lib/newwrap/tcl.nim b/lib/newwrap/tcl.nim
index d62a54c2d..d62a54c2d 100644..100755
--- a/lib/newwrap/tcl.nim
+++ b/lib/newwrap/tcl.nim
diff --git a/lib/pure/sockets.nim b/lib/pure/sockets.nim
index 0f9221b37..be2e4434a 100644..100755
--- a/lib/pure/sockets.nim
+++ b/lib/pure/sockets.nim
@@ -66,6 +66,8 @@ const
 proc `==`*(a, b: TSocket): bool {.borrow.}
 proc `==`*(a, b: TPort): bool {.borrow.}
 
+proc `$`* (p: TPort): string = result = $ze(int16(p))
+
 proc ToInt(domain: TDomain): cint =
   case domain
   of AF_UNIX:        result = posix.AF_UNIX
diff --git a/llvm/llvm.nim b/llvm/llvm.nim
index d010457f8..d010457f8 100644..100755
--- a/llvm/llvm.nim
+++ b/llvm/llvm.nim
diff --git a/llvm/llvm_orig.nim b/llvm/llvm_orig.nim
index 8e09f9c68..8e09f9c68 100644..100755
--- a/llvm/llvm_orig.nim
+++ b/llvm/llvm_orig.nim
diff --git a/rod/llvmtype.nim b/rod/llvmtype.nim
index 7790855ac..7790855ac 100644..100755
--- a/rod/llvmtype.nim
+++ b/rod/llvmtype.nim
diff --git a/rod/scanner.nim b/rod/scanner.nim
index 2036a4d4d..9382c7621 100755
--- a/rod/scanner.nim
+++ b/rod/scanner.nim
@@ -408,7 +408,6 @@ proc handleDecChars(L: var TLexer, xi: var int) =
     inc(L.bufpos)
 
 proc getEscapedChar(L: var TLexer, tok: var TToken) = 
-  var xi: int
   inc(L.bufpos)               # skip '\'
   case L.buf[L.bufpos]
   of 'n', 'N': 
@@ -447,14 +446,14 @@ proc getEscapedChar(L: var TLexer, tok: var TToken) =
     Inc(L.bufpos)
   of 'x', 'X': 
     inc(L.bufpos)
-    xi = 0
+    var xi = 0
     handleHexChar(L, xi)
     handleHexChar(L, xi)
     add(tok.literal, Chr(xi))
   of '0'..'9': 
     if matchTwoChars(L, '0', {'0'..'9'}): 
       lexMessage(L, warnOctalEscape)
-    xi = 0
+    var xi = 0
     handleDecChars(L, xi)
     if (xi <= 255): add(tok.literal, Chr(xi))
     else: lexMessage(L, errInvalidCharacterConstant)
@@ -505,8 +504,7 @@ proc getString(L: var TLexer, tok: var TToken, rawMode: bool) =
       else: 
         add(tok.literal, buf[pos])
         Inc(pos)
-    L.bufpos = pos +
-        3                     # skip the three """
+    L.bufpos = pos + 3 # skip the three """
   else: 
     # ordinary string literal
     if rawMode: tok.tokType = tkRStrLit
@@ -787,4 +785,4 @@ proc rawGetTok(L: var TLexer, tok: var TToken) =
         lexMessage(L, errInvalidToken, c & " (\\" & $(ord(c)) & ')')
         Inc(L.bufpos)
   
-dummyIdent = getIdent("")
\ No newline at end of file
+dummyIdent = getIdent("")
diff --git a/tests/tfinally.nim b/tests/tfinally.nim
index 102444e82..df6397125 100755
--- a/tests/tfinally.nim
+++ b/tests/tfinally.nim
@@ -6,5 +6,5 @@ proc main: int =
   finally: 
     echo "came here"
     
-echo main()
+discard main() #OUT came here
 
diff --git a/tests/tmatrix.nim b/tests/tmatrix.nim
index a64ac0395..a162d0f10 100644..100755
--- a/tests/tmatrix.nim
+++ b/tests/tmatrix.nim
@@ -21,18 +21,18 @@ proc `[,]`*(m: TMatrix, x, y: int): float {.inline.} =
 proc `[,]=`*(m: var TMatrix, x, y: int, val: float) {.inline.} =
   m.data[x|y] = val
   
-proc `[$..$, $..$]`*(m: TMatrix, a, b, c, d: int): TMatrix =
+proc `[$ .. $, $ .. $]`*(m: TMatrix, a, b, c, d: int): TMatrix =
   result = createMatrix(b-a+1, d-c+1)
   for x in a..b:
     for y in c..d:
       result[x-a, y-c] = m[x, y]
 
-proc `[$..$, $..$]=`*(m: var TMatrix, a, b, c, d: int, val: float) =
+proc `[$ .. $, $ .. $]=`*(m: var TMatrix, a, b, c, d: int, val: float) =
   for x in a..b:
     for y in c..d:
       m[x, y] = val
 
-proc `[$..$, $..$]=`*(m: var TMatrix, a, b, c, d: int, val: TMatrix) =
+proc `[$ .. $, $ .. $]=`*(m: var TMatrix, a, b, c, d: int, val: TMatrix) =
   assert val.width == b-a+1
   assert val.height == d-c+1
   for x in a..b:
@@ -57,4 +57,4 @@ for i in 0..w-1:
   m[i, i] = 1.0
 
 for i in 0..w-1:
-  stdout.write(m[i,i]) #OUT 1.01.01.0
+  stdout.write(m[i,i]) #OUT 111
#n1592'>1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350