changeset 21127:647f571f54da

Merge
author Stefan Anzinger <stefan.anzinger@oracle.com>
date Mon, 27 Apr 2015 19:03:52 +0200
parents 6e05dd55d795 85b0935625c1
children 0f289b082d3d
files
diffstat 2 files changed, 39 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/mx/mx_graal.py	Mon Apr 27 18:37:10 2015 +0200
+++ b/mx/mx_graal.py	Mon Apr 27 19:03:52 2015 +0200
@@ -682,14 +682,17 @@
                     assert serviceName and member == 'META-INF/services/' + serviceName
                     with zf.open(member) as serviceFile:
                         serviceImpls = servicesMap.setdefault(serviceName, [])
-                        serviceImpls.extend(serviceFile.readlines())
+                        for line in serviceFile.readlines():
+                            line = line.strip()
+                            if line:
+                                serviceImpls.append(line)
     graalServices = _filterGraalService(servicesMap.keys(), graalJars)
     for serviceName in graalServices:
         serviceImpls = servicesMap[serviceName]
         fd, tmp = tempfile.mkstemp(prefix=serviceName)
         f = os.fdopen(fd, 'w+')
         for serviceImpl in serviceImpls:
-            f.write(serviceImpl.rstrip() + os.linesep)
+            f.write(serviceImpl + os.linesep)
         target = join(destination, serviceName)
         f.close()
         shutil.move(tmp, target)
--- a/src/share/vm/graal/graalRuntime.cpp	Mon Apr 27 18:37:10 2015 +0200
+++ b/src/share/vm/graal/graalRuntime.cpp	Mon Apr 27 19:03:52 2015 +0200
@@ -1099,19 +1099,43 @@
         GrowableArray<char*>* implNames = new GrowableArray<char*>();
         char* line = buffer;
         while (line - buffer < num_read) {
-          char* nl = strchr(line, '\n');
-          if (nl != NULL) {
-            *nl = '\0';
+          // find line end (\r, \n or \r\n)
+          char* nextline = NULL;
+          char* cr = strchr(line, '\r');
+          char* lf = strchr(line, '\n');
+          if (cr != NULL && lf != NULL) {
+            char* min = MIN2(cr, lf);
+            *min = '\0';
+            if (lf == cr + 1) {
+              nextline = lf + 1;
+            } else {
+              nextline = min + 1;
+            }
+          } else if (cr != NULL) {
+            *cr = '\0';
+            nextline = cr + 1;
+          } else if (lf != NULL) {
+            *lf = '\0';
+            nextline = lf + 1;
           }
-          // Turn all '.'s into '/'s
-          for (size_t index = 0; line[index] != '\0'; index++) {
-            if (line[index] == '.') {
-              line[index] = '/';
+          // trim left
+          while (*line == ' ' || *line == '\t') line++;
+          char* end = line + strlen(line);
+          // trim right
+          while (end > line && (*(end -1) == ' ' || *(end -1) == '\t')) end--;
+          *end = '\0';
+          // skip comments and empty lines
+          if (*line != '#' && strlen(line) > 0) {
+            // Turn all '.'s into '/'s
+            for (size_t index = 0; line[index] != '\0'; index++) {
+              if (line[index] == '.') {
+                line[index] = '/';
+              }
             }
+            implNames->append(line);
           }
-          implNames->append(line);
-          if (nl != NULL) {
-            line = nl + 1;
+          if (nextline != NULL) {
+            line = nextline;
           } else {
             // File without newline at the end
             break;