From 09bac070104dadc79e43a127bf7bdfcd180840d0 Mon Sep 17 00:00:00 2001
From: geby <geby@7c85be65-684b-0410-a082-b2ed4fbef004>
Date: Wed, 13 Jun 2012 13:43:32 +0000
Subject: [PATCH] synaser.pas - GetSerialPortNames (Linux) - repaired and
 compatible with Windows variant.

git-svn-id: https://svn.code.sf.net/p/synalist/code/trunk@157 7c85be65-684b-0410-a082-b2ed4fbef004
---
 synaser.pas | 39 +++++++++++++++------------------------
 1 file changed, 15 insertions(+), 24 deletions(-)

diff --git a/synaser.pas b/synaser.pas
index 3628a36..7ef739c 100644
--- a/synaser.pas
+++ b/synaser.pas
@@ -1,9 +1,9 @@
 {==============================================================================|
-| Project : Ararat Synapse                                       | 007.005.002 |
+| Project : Ararat Synapse                                       | 007.005.003 |
 |==============================================================================|
 | Content: Serial port support                                                 |
 |==============================================================================|
-| Copyright (c)2001-2011, Lukas Gebauer                                        |
+| Copyright (c)2001-2012, Lukas Gebauer                                        |
 | All rights reserved.                                                         |
 |                                                                              |
 | Redistribution and use in source and binary forms, with or without           |
@@ -33,7 +33,7 @@
 | DAMAGE.                                                                      |
 |==============================================================================|
 | The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
-| Portions created by Lukas Gebauer are Copyright (c)2001-2011.                |
+| Portions created by Lukas Gebauer are Copyright (c)2001-2012.                |
 | All Rights Reserved.                                                         |
 |==============================================================================|
 | Contributor(s):                                                              |
@@ -2309,30 +2309,21 @@ end;
 {$IFNDEF MSWINDOWS}
 function GetSerialPortNames: string;
 var
-  Index: Integer;
-  Data: string;
-  TmpPorts: String;
   sr : TSearchRec;
 begin
-  try
-    TmpPorts := '';
-    if FindFirst('/dev/ttyS*', $FFFFFFFF, sr) = 0 then
-    begin
-      repeat
-        if (sr.Attr and $FFFFFFFF) = Sr.Attr then
-        begin
-          data := sr.Name;
-          index := length(data);
-          while (index > 1) and (data[index] <> '/') do
-            index := index - 1;
-          TmpPorts := TmpPorts + ' ' + copy(data, 1, index + 1);
-        end;
-      until FindNext(sr) <> 0;
-    end;
-    FindClose(sr);
-  finally
-    Result:=TmpPorts;
+  Result := '';
+  if FindFirst('/dev/ttyS*', $FFFFFFFF, sr) = 0 then
+  begin
+    repeat
+      if (sr.Attr and $FFFFFFFF) = Sr.Attr then
+      begin
+        if Result <> '' then
+          Result := Result + ',';
+        Result := Result + sr.Name;
+      end;
+    until FindNext(sr) <> 0;
   end;
+  FindClose(sr);
 end;
 {$ENDIF}